Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guidance Needed: Using MaveDB API to Search for Data #353

Open
GodkingRadriar opened this issue Nov 7, 2024 · 2 comments
Open

Guidance Needed: Using MaveDB API to Search for Data #353

GodkingRadriar opened this issue Nov 7, 2024 · 2 comments

Comments

@GodkingRadriar
Copy link

Hi,

I'm new to MaveDB and to APIs in general. I checked the repository and the documentation at https://api.mavedb.org/docs but still feel uncertain about where to start.

For example, I’m trying to perform a search query for “TP53” and retrieve all relevant results. Could someone please guide me on how to structure the Python code for this, using either this repository or the API directly?

Thank you!

@EstelleDa
Copy link
Member

EstelleDa commented Nov 11, 2024

Would you only like to read the search results or, get the data and do more data processing?
If you only need to do some searches, using MaveDB website will be easier. For example, https://mavedb.org/search?search=TP53

@bencap
Copy link
Collaborator

bencap commented Nov 12, 2024

Hi @GodkingRadriar,

You can interact with the API via the command line with curl. The request that you outlined looks like this:

curl -d '{"text":"TP53"}' -H "Content-Type: application/json" -X POST https://api.mavedb.org/api/v1/score-sets/search

Feel free to use any of those keys that the docs show you in place of text (which is just a basic substring search across all of the fields in a score set). For instance, to get score sets with TP53 in the name of the target you could send the following request:

curl -d '{"targets":["TP53"]}' -H "Content-Type: application/json" -X POST https://api.mavedb.org/api/v1/score-sets/search

This will return a list of JSON objects, each one representing one score set which matches your request. To do the same thing in Python, you could use the requests module:

import requests

search_dict = {
    "text": "TP53",
}

response = requests.post(
    "https://api.mavedb.org/api/v1/score-sets/search",
    json=search_dict,
)
search_results = response.json()

The search results object will contain a list of dictionaries, with each dictionary representing a single score set matching your search. Again, feel free to combine any of the keys shown in the documentation within the defined search dictionary if you'd like more granular searches.

Hope that helps, and lmk if that raises any other questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants