MolecularMatch/mm-public-scripts

How to use fields section of Molecular Match API

Closed this issue · 7 comments

Hi, I am trying to utilise fields section of /drug/search api by passing it as "fields":["rows"], but it is displaying everything in the response instead of only rows section.

Hello,

Sorry for the late reply. This is an old project that hasn't been maintained for quite some time. I'm happy to point you to better documentation regarding interacting with our search endpoints.

You are wondering how to limit the fields payload. The fields attribute pertains to the objects within the rows array. Within rows is the actual drug records in this case. To start, I would recommend running this meta query which lists the full set of available fields for the drug record. You can do the same for publications and trials if desired:
curl https://api.molecularmatch.com/v5/drug/meta -H "Content-Type:application/json" -H "Authorization: Bearer " -d '{
}'

Those field names can be used within the search request 'fields' array to limit results. An example would be:

curl -X POST api.molecularmatch.com/v5/drug/search -H "Content-Type:application/json" -H "Authorization: Bearer " -d '{
"fields": ["id", "name"],
"filters": [
{
"facet":"CONDITION",
"term":"Lung Cancer",
"filterType": "must_include"
}
]
}'

Upon inspection of the result you will notice that the records within the rows array contain 'id' and 'name' fields. You will always receive the missing and matching attributes which indicate feedback as to how the record is matching (direct match, ontological parent match, inferred match from a distant concept, etc). With the drug search endpoint you will also automatically receive a tier value which indicates the level of clinical evidence pertaining to the drug recommendation.

you have to include your api key in these requests. further information can be found at

https://api.molecularmatch.com/#drugs

@nicktackes Thanks for your response. I think there is no way I can get only state and country section of the locations for the trials and that too only nearest location from the provided location right. I have observed there is a section called locationSummary which provides summary of the locations and also nearest location. But even that gives some other data which is not neccessary making the response time long.

@nicktackes That would be great as it make querying very simpler giving more flexibility and also response time will get improved. Thank you!

sub object fields are now supported in V5 trial, drug and publication search. Here is an example of trial search with subfields specified for an array (locations) and an object (overallContact). Only 1 level of depth is supported.

On a broader note, I believe you are working for Omics? How are things proceeding with respect to the MolecularMatch search? Is your application in a production state and have you onboarded customers? just curious how everything is going.

curl -X POST https://api.molecularmatch.com/v5/trial/search -H "Content-Type:application/json" -H "Authorization: Bearer your api key" -d '{
"fields": ["id", "title", "locations.state", "locations.country", "locations.name", "locations.status", "overallContact.last_name", "overallContact.email"],
"limit": 3,
"filters": [
{
"facet":"MUTATION",
"term":"KRAS G12C",
"filterType": "must_include"
}
]
}'

sub object fields are now supported in V5 trial, drug and publication search. Here is an example of trial search with subfields specified for an array (locations) and an object (overallContact). Only 1 level of depth is supported.

On a broader note, I believe you are working for Omics? How are things proceeding with respect to the MolecularMatch search? Is your application in a production state and have you onboarded customers? just curious how everything is going.

curl -X POST https://api.molecularmatch.com/v5/trial/search -H "Content-Type:application/json" -H "Authorization: Bearer your api key" -d '{ "fields": ["id", "title", "locations.state", "locations.country", "locations.name", "locations.status", "overallContact.last_name", "overallContact.email"], "limit": 3, "filters": [ { "facet":"MUTATION", "term":"KRAS G12C", "filterType": "must_include" } ] }'

I have tested it. However, I wanted to get the nearest state and country i.e., nearestLocation from the provided zip code but the current behavior returns everything. I think I can do the required implementation from my side itself by utilising locationSummary.

But, Thanks for your response. Everything is going great.