Package: yupdates
Yupdates Python SDKThe Yupdates Python SDK lets you easily use the Yupdates API from your own software and scripts.This ishosted on GitHub. There is also aYupdates Rust SDK.RequirementsThe Python SDK haszero external dependencies. It is written so that you can easily drop it into your scripts, Lambda functions, and bigger projects without any dependency needs or conflicts.It requires Python 3.7 or higher.You will need an API token from the application. Navigate to "Settings" and then "API".The examples below start with read-only operations, so you can use the general, read-only token to get started.InstallationBefore running the following commands, we assume you have set up your environment (pyenv, virtualenv, etc.).Install the SDK viapip.$pipinstallyupdatesOr, install from source:$gitclonegit://github.com/yupdates/yupdates-sdk-py.git
$cdyupdates-sdk-py
$pipinstall.Set the API token environment variable:$set+ohistory$exportYUPDATES_API_TOKEN="1a7814fc25:c38bb526..."$set-ohistoryNow test the connection and authentication. This will work from a Python shell or script:fromyupdatesimportyapiprint(yapi.ping())If there is anything but a 200 response, it will throw an exception. Otherwise, this will print out the JSON response which is returned from thepingfunction deserialized into a Python dict.Thepingoperation is helpful to run in the beginning of your scripts to make sure there are no setup issues.Another way to use the SDK is to instantiate a client once and use it repeatedly:fromyupdates.clientimportyupdates_clientyup=yupdates_client()print(yup.ping())Read items from a feedfromyupdatesimportyapifeed_id='02fb24a4478462a4491067224b66d9a8b2338dada2737'feed_items=yapi.read_items(feed_id)# See client.py for optional parametersforfeed_iteminfeed_items:print(feed_item.title)# See models.py and API docs for field descriptionsWrite items to a feedTo write items, you cannot use the read-only API token anymore. Obtain a token with write privileges by adding an API input to a feed in the app, and set theYUPDATES_API_TOKENenvironment variable as you did above.fromyupdates.clientimportyupdates_clientfromyupdates.modelsimportInputItemyc=yupdates_client()item=InputItem("a title","some content","https://www.example.com/something")yc.new_items([item])The API token is feed-specific, which is why there is no other configuration needed. You make one configuration (the API token) and Yupdates figures out the rest on the server side.That is for convenience, but it also means there's only one permission to reason about, and a small blast radius if it's exposed. The token is authorized to add items to one, single feed, and it cannot do anything else (not even read items). You're not dropping a master key into a cronjob script or Lambda function or wherever it's going to run.In the future, it will be possible to obtain a token with wider writer privileges, so you can add items to multiple feeds.Getting helpYou can create aGitHub issueon this repository for bugs and feature requests.The fastest way to get help is to create a support ticket from the Yupdates application. Or emailsupport@yupdates.com. Especially if you need help that is not specific to this SDK, or if you would like more hands-on setup and troubleshooting advice.ConventionsThis library follows theNumpy docstring conventions.LicenseThe SDK is distributed under the MIT license, please seeLICENSEfor more information.This covers the source code and examples, but it does not cover related items like the Yupdates logo or API documentation which is not hosted here.