safecast api的python包装器。

Safecast的Python项目详细描述


保险箱

一个围绕safecast api的纯python包装器。

通过YtoTech members。查看我们相关的blog post

简介

这个库为Safecast API提供了一个纯python接口。

Safecast提供开放的硬件和平台来测量和共享有关人员环境的数据。目前,safecast api允许发布辐射测量数据。

正如他们所说:

We believe that having more freely available open data is better for everyone.

安装

您可以使用:

$ pip install SafecastPy

PyPI version

开始

首先,您需要前往https://api.safecast.org/en-US/users/sign_up并注册一个新帐户!

注册后,从配置文件选项卡中获取您的帐户API key

您还可以从在safecast apidevelopment instance上测试应用程序开始。

首先,您需要导入safecastpy:

importSafecastPy

动态函数参数

函数的关键字参数映射到safecast api文档中每个端点可用的函数。这样做可以让我们在查询SAFECAST API时具有难以置信的灵活性,所以API的更改不会被您从库中使用。

基本用法

所有的方法定义都可以通过阅读SafecastPy/endpoints.py找到。

初始化

使用api密钥创建safecastpy实例:

importSafecastPysafecast=SafecastPy.SafecastPy(api_key='YOUR_API_KEY')

默认情况下,它使用safecast api生产实例。您可能需要使用开发实例:

importSafecastPysafecast=SafecastPy.SafecastPy(api_key='YOUR_API_KEY',api_url=SafecastPy.DEVELOPMENT_API_URL)

获取测量值

# Get the 25 last added measurements.safecast.get_measurements(order='created_at desc'))# Use paging to navigate through the results.foriinrange(2,10):safecast.get_measurements(order='created_at desc',page=i))# You can also filter by unit.safecast.get_measurements(unit=SafecastPy.UNIT_CPM)))# Or date.safecast.get_measurements(since='2015-09-08',until='2016-12-22')# And use a combination of all of that.safecast.get_measurements(since='2015-09-08',until='2016-12-22',unit=SafecastPy.UNIT_USV,order='created_at asc',page=20)

获取有关the API documentation上可用参数的详细信息。

添加测量值

importdatetime,randommeasurement=safecast.add_measurement(json={'latitude':49.418683,'longitude':2.823469,'value':random.uniform(1,10),'unit':SafecastPy.UNIT_CPM,'captured_at':datetime.datetime.utcnow().isoformat()+'+00:00','device_id':90,'location_name':'1 Rue du Grand Ferré, Compiègne','height':120})print('New measurement id: {0}'.format(measurement['id']))

检索测量值

safecast.get_measurement(id=52858985)

上传bgeige导入

bgeigie_import=safecast.upload_bgeigie_import(files={'bgeigie_import[source]':open('misc/sample_bgeigie.LOG','rb')},data={'bgeigie_import[name]':'Logging in Compiègne','bgeigie_import[description]':'Around the Université de Technologie','bgeigie_import[credits]':'by YtoTech team','bgeigie_import[cities]':'Compiègne','bgeigie_import[orientation]':'NWE','bgeigie_import[height]':'100'})print('New import id: {0}'.format(bgeigie_import['id']))

你喜欢自由行吗?你可以退房our blog

你也可以在yoan@ytotech.com给我们发情书、提问或发表任何评论。

快乐黑客!

贡献

随时可以open a new ticket或者提交一个pr来改进lib。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
解释java选择方法   连接到127.0.0.1的java间歇性故障,连接到IP(eth0)时没有故障   java如何优雅地杀死hadoop作业/intercept`hadoop作业杀死`   java如何通过引导类加载器以编程方式加载另一个类?   url Java:在查询参数之前使用片段构建URI   在BroadLeaf表blc_order_属性中保存OrderAttributes值时发生java错误   安卓将功能从xml转换为java   java如何将数据写入文件?   java JPA SQL结果映射   Java中整数对象比较运算符的引用安全性   Spring测试失败:java。lang.NoClassDefFoundError:org/springframework/cglib/transform/impl/memorysafuendecaredthrowableStrategy   rich:extendedDataTable中的java行选择和数据处理   java为什么我需要在volatile上对多个线程使用synchronized?   java尽管构建成功,但为什么会出现此错误?   数组$ArrayList不能转换为java。util。java中的ArrayList   java如何根据泛型类型调用方法?   java将JLabel添加到JPanel,将JPanel添加到JFrame   如果MapStruct中的源为null,则java将父目标设置为null   JavaJBossDrools从DRL插入事实   java不同的JRE安装(windows)