Skip to main content

Querying neuromorpho.org database with Python requests

Project description

neuromorpho-api

Querying the neuromorpho.org database in Python with requests.

As of May 2024, the SSL key for neuromorpho.org has been updated, and the
workaround packaged here is no longer necessary!
The [requests](https://pypi-hypernode.com/project/requests/) package can now be used
directly with the neuromorpho.org API.
This project will be archived, though the documentation will remain live and
updated to demonstrate programmatic access of neuromorpho data.

Quickstart

>>> import requests

>>> neuron_endpoint = "https://neuromorpho.org/api/neuron/"
>>> resp = requests.get(neuron_endpoint + "fields")
>>> resp.json()
{'Neuron Fields': ['neuron_id',
  'neuron_name',
  'archive',
  'age_scale',
  'gender',
  ...

See the tutorial for more detailed examples, including selecting neurons by attribute pattern matching and downloading SWC traces.


What is was this package?

The neuromorpho-api package provides a requests.Session instance with a custom SSLContext needed for interacting with neuromorpho.org.

Why can't I just use requests directly?

NOTE: should no longer be an issue as of 05-24

You may see something like the following:

>>> import requests
>>> requests.get("https://neuromorpho.org/api/neuron/id/1")
Traceback (most recent call last)
   ...
SSLError: HTTPSConnectionPool(host='neuromorpho.org', port=443): Max retries exceeded with url: /api/neuron/id/1 (Caused by SSLError(SSLError(1, '[SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1006)')))

It appears the key provided by neuromorpho.org is incompatible with the default Python SSL cipher. This package works around this issue using Robin De Schepper's solution posted on Stack Overflow. At some point in the future, the neuromorpho certificate may (hopefully) be updated, at which point this package will be archived.

Future compatibility

The requestor provided by this package is intended as a temporary workaround for the current DH key issue with neuromorpho.org. If the neuromorpho.org certificate is updated, the requestor with the custom SSLContext will no longer be necessary, and users can switch to using requests directly. Therefore, the following import alias is recommended:

from neuromorpho-api import requestor as requests

With an updated certificate, the above can be changed to:

import requests

and all code that depends on requests.get should continue to work as expected.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neuromorpho_api-0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

neuromorpho_api-0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file neuromorpho_api-0.2.tar.gz.

File metadata

  • Download URL: neuromorpho_api-0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for neuromorpho_api-0.2.tar.gz
Algorithm Hash digest
SHA256 b9e7a76eba5cdc16ce55e6866f02739ff4f01324bf7759bcb05523f8d7eb7ac1
MD5 ef230fbba28a266fc719fa566e67460d
BLAKE2b-256 efc3aba2abe714cd05b23ada0579335f3004fbe44e9e0f163cfa6a47074ae0b6

See more details on using hashes here.

File details

Details for the file neuromorpho_api-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for neuromorpho_api-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dbc81f2f90c46be423e3879eb888fa449716040f3f6cdc3ab750fefcedafc4c0
MD5 c0d45850f92d532049a6048cad66ee5e
BLAKE2b-256 44b54a97274f6fbee7ffcaf066a833d1b0b82d6f2f73f14ab1eede528262a24e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page