使用Python requests查询neuromorpho.org数据库
项目描述
neuromorpho-api
使用requests查询neuromorpho.org数据库。
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.ac.cn/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.
快速入门
>>> 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',
...
请参阅教程以获取更详细的示例,包括按属性模式匹配选择神经元和下载SWC迹线。
这个包是什么?
neuromorpho-api
包提供了一个带有自定义SSLContext
的requests.Session
实例,用于与neuromorpho.org交互。
为什么不能直接使用requests
?
注意:自05-24起不应再是问题
您可能会看到以下内容
>>> 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)')))
这似乎是neuromorpho.org提供的密钥与默认Python SSL加密方式不兼容。此包使用Robin De Schepper在Stack Overflow上发布的解决方案解决这个问题。将来某个时候,neuromorpho证书可能会(希望)更新,届时此包将被存档。
未来兼容性
此包提供的requestor
旨在作为解决当前neuromorpho.org DH密钥问题的临时解决方案。如果neuromorpho.org证书更新,则不再需要带有自定义SSLContext的requestor
,用户可以直接使用requests
。因此,建议以下导入别名
from neuromorpho-api import requestor as requests
更新证书后,以上内容可以更改为
import requests
所有依赖于 requests.get
的代码应继续按预期工作。
项目详情
关闭
neuromorpho_api-0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b9e7a76eba5cdc16ce55e6866f02739ff4f01324bf7759bcb05523f8d7eb7ac1 |
|
MD5 | ef230fbba28a266fc719fa566e67460d |
|
BLAKE2b-256 | efc3aba2abe714cd05b23ada0579335f3004fbe44e9e0f163cfa6a47074ae0b6 |
关闭
neuromorpho_api-0.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | dbc81f2f90c46be423e3879eb888fa449716040f3f6cdc3ab750fefcedafc4c0 |
|
MD5 | c0d45850f92d532049a6048cad66ee5e |
|
BLAKE2b-256 | 44b54a97274f6fbee7ffcaf066a833d1b0b82d6f2f73f14ab1eede528262a24e |