greenelab / connectivity-search-backend

Django backend for hetnet connectivity search
https://search-api.het.io
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

Web API for Node search #17

Closed dongbohu closed 5 years ago

dongbohu commented 5 years ago

This PR adds a simple REST API that supports Node search. Here is an example: http://34.233.249.241/api/v1/nodes/?search=abc

By default, it shows only 25 results. To get all of them, use the limit parameter: http://34.233.249.241/api/v1/nodes/?search=abc&limit=100000

I also removed frontend test in CircleCI, because this repo is supposed to be backend only.

dongbohu commented 5 years ago

Forgot to mention: CORS (Cross-Origin Resource Sharing) is enabled so that anybody can GET from the URL <host>/api/v1/.... It will make the frontend development easier.

dhimmel commented 5 years ago

Here is the output of

curl --silent 'http://34.233.249.241/api/v1/nodes/?search=multiple' | python -m json.tool
```json { "count": 7, "next": null, "previous": null, "results": [ { "id": 14803, "identifier": "DOID:2377", "identifier_type": "str", "name": "multiple sclerosis", "url": "http://purl.obolibrary.org/obo/DOID_2377", "data": { "url": "http://purl.obolibrary.org/obo/DOID_2377", "source": "Disease Ontology", "license": "CC BY 3.0" }, "metanode": "Disease" }, { "id": 40866, "identifier": "C0000772", "identifier_type": "str", "name": "Multiple congenital abnormalities", "url": "http://identifiers.org/umls/C0000772", "data": { "url": "http://identifiers.org/umls/C0000772", "source": "UMLS via SIDER 4.1", "license": "CC BY-NC-SA 4.0" }, "metanode": "Side Effect" }, { "id": 41436, "identifier": "C0016655", "identifier_type": "str", "name": "Multiple fractures", "url": "http://identifiers.org/umls/C0016655", "data": { "url": "http://identifiers.org/umls/C0016655", "source": "UMLS via SIDER 4.1", "license": "CC BY-NC-SA 4.0" }, "metanode": "Side Effect" }, { "id": 41872, "identifier": "C0026769", "identifier_type": "str", "name": "Multiple sclerosis", "url": "http://identifiers.org/umls/C0026769", "data": { "url": "http://identifiers.org/umls/C0026769", "source": "UMLS via SIDER 4.1", "license": "CC BY-NC-SA 4.0" }, "metanode": "Side Effect" }, { "id": 42120, "identifier": "C0032989", "identifier_type": "str", "name": "Multiple pregnancy", "url": "http://identifiers.org/umls/C0032989", "data": { "url": "http://identifiers.org/umls/C0032989", "source": "UMLS via SIDER 4.1", "license": "CC BY-NC-SA 4.0" }, "metanode": "Side Effect" }, { "id": 44994, "identifier": "C0740281", "identifier_type": "str", "name": "Multiple allergies", "url": "http://identifiers.org/umls/C0740281", "data": { "url": "http://identifiers.org/umls/C0740281", "source": "UMLS via SIDER 4.1", "license": "CC BY-NC-SA 4.0" }, "metanode": "Side Effect" }, { "id": 45382, "identifier": "C0856120", "identifier_type": "str", "name": "Multiple sclerosis relapse", "url": "http://identifiers.org/umls/C0856120", "data": { "url": "http://identifiers.org/umls/C0856120", "source": "UMLS via SIDER 4.1", "license": "CC BY-NC-SA 4.0" }, "metanode": "Side Effect" } ] } ```
dongbohu commented 5 years ago

@dhimmel: If you have jq installed (apt install jq), you can also do: curl --silent 'http://34.233.249.241/api/v1/nodes/?search=multiple' | jq The output is nicer because it is in color.