https://api.atomx.com上atomxapi的python接口

atomx的Python项目详细描述


atomx rest api的接口。

有关详细信息,请阅读全文 documentation online, 在github中报告错误 或者查看atomx wiki

示例用法

fromatomximportAtomx# create atomx sessionatomx=Atomx('user@example.com','password')# get 10 creativescreatives=atomx.get('Creatives',limit=10)# the result is a list of `atomx.models.Creative` models# that you can easily inspect, manipulate and updateforcreativeincreatives:print('Creative ID: {c.id}, state: {c.state}, ''name: {c.name}, title: {c.title}'.format(c=creative))# update title for the first creative in listcreative=creatives[0]creative.title='shiny new title'# the session is inherited from `atomx` that made the get requestcreative.save()# create a new profilefromatomx.modelsimportProfileprofile=Profile(advertiser_id=23,name='test profile')# Note that you have to pass it a valid `Atomx` session for create# or use `atomx.create(profile)`profile.create(atomx)# now you could alter and update it like the creative aboveprofile.name='changed name'profile.save()# you can also get attributesprofiles=atomx.get('advertiser',88,'profiles')# equivalent is to pass the complete resource path as string instead of argumentsprofiles=atomx.get('advertiser/88/profiles')# same as above# profiles is now a list of `atomx.models.Profile` that you can# read, update, etc again.profiles[0].click_frequency_cap_per=86400profiles[0].save()# working with searchs=atomx.search('mini*')# s is now a dict with lists of search results for the different models# with the model id and namepublisher=s['publisher'][0]# get the first publisher..publisher.reload()# .. and load all the dataprint(publisher)# now all publisher data is therepublisher.history()# gets all changes made to this publisher# reporting example# get a report for a specific publisherreport=atomx.report(scope='publisher',groups=['hour'],metrics=['impressions','clicks'],where=[['publisher_id','==',42]],from_='2015-02-08 00:00:00',to='2015-02-09 00:00:00',timezone='America/Los_Angeles')# check if report is readyprint(report.is_ready)# if pandas is installed you can get the pandas dataframe with `report.pandas`# you can also get the report csv in `report.content` without pandasdf=report.pandas# A datetime index is automatically set when group by a hour/day/month.# calculate mean, median, std per hourmeans=df.resample('H',how=['mean','median','std'])# and plot impression and clicks per daymeans['impressions'].plot()means['clicks'].plot()

安装

要安装python atomx api,只需:

$ pip install atomx

或者如果您想使用ipython笔记本和报告功能:

$ pip install atomx[report]

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

推荐PyPI第三方库


热门话题
java提供了大量的Quartz工作线程   来自SOAPException的java抛出超时异常   java通过REST web服务同步PostgreSQL过程调用   java Hibernate:在关联表中设置值   javaimapidlechanneladapterjavax。邮政AuthenticationFailedException:[警报]同时连接太多   JavaApacheStorm:stormkafkamonitor脚本引发异常   java将jar链接到战争   Matlab与Java的集成方法   安卓公司。谷歌。ads.AdView未能实例化java。lang.ClassNotFoundException:org。json。JSONException   “String forecastStr=mForecastAdapter.getItem(position);”行中出现java错误阳光工程   java如何将Mono中的列表属性作为流量进行操作?   java DecimalFormat类不必要地给出整数   java@IfProfileValue两个spring配置文件   java如何使用SwingWorker创建多线程?   java从扩展SwingWorker的内部类触发事件   java二叉树高度实现