Quickstart¶
Install neuprint-python¶
If you’re usingconda, use this command:
condainstall-cflyem-forgeneuprint-python
Otherwise, usepip
:
pipinstallneuprint-python
Client and Authorization Token¶
All communication with theneuPrintHTTP
server is done via aClient
object.
To create aClient
, you must provide three things:
The neuprint server address (e.g.
neuprint.janelia.org
)Which dataset you’ll be fetching from (e.g.
hemibrain:v1.2.1
)Your personal authentication token
To obtain your authorization token, follow these steps:
Navigate your web browser to the neuprint server address.
Log in.
Using the account menu in the upper right-hand corner, select “Account” as shown in the screenshot below.
Copy the entire auth token.

Create the Client¶
fromneuprintimportClientc=Client('neuprint.janelia.org',dataset='hemibrain:v1.2.1',token='YOUR-TOKEN-HERE')c.fetch_version()
Alternatively, you can set your token in the following environment variable, in which case thetoken
parameter can be omitted:
$exportNEUPRINT_APPLICATION_CREDENTIALS=<my-token>
Execute a query¶
Use yourClient
to request data from neuprint.
TheClient.fetch_custom()
method will run an arbitrary cypher query against the database.For information about the neuprint data model, see theneuprint explorer web help.
Also,neuprint-python
comes with convenience functions to implement common queries. SeeQueries.
In [1]:## This query will return all neurons in the ROI ‘AB’ ...:## that have greater than 10 pre-synaptic sites. ...:## Results are ordered by total synaptic sites (pre+post). ...:q="""\ ...: MATCH (n :Neuron {`AB(R)`: true}) ...: WHERE n.pre > 10 ...: RETURN n.bodyId AS bodyId, n.type as type, n.instance AS instance, n.pre AS numpre, n.post AS numpost ...: ORDER BY n.pre + n.post DESC ...:"""In [2]:results=c.fetch_custom(q)In [3]:print(f"Found{len(results)} results")Found 177 resultsIn [4]:results.head()Out[4]: bodyId type instance numpre numpost0 5813027016 FB4Y FB4Y(EB/NO1)_R 1720 65081 1008378448 FB4Y FB4Y(EB/NO1)_R 1791 63012 1513363614 LCNOpm LCNOpm(LAL-NO3pm)_R 858 65013 5813057274 FB4Y FB4Y(EB/NO1)_L 2001 50894 1131827390 FB4M FB4M(PPM3-FB3/4-NO-DAN)_R 2614 4431
Next Steps¶
Try theinteractive tutorial for a tour of basic features inneuprint-python
.