Package: atsdk
The atPlatform for Python developers - (Beta Version)This repo contains library, samples and examples for developers who wish
to work with the atPlatform from Python code.Getting Started1. InstallationThis package can be installed from PyPI with:pipinstallatsdkAlternatively clone this repo and from the repo root:pipinstall-rrequirements.txt
pipinstall.2. Setting up your.atKeysTo run the examples save .atKeys file in the '~/.atsign/keys/' directory.3. Sending and Receiving DataThere are 3 ways in which data can be sent and received from at server.Using PublicKeyfromat_clientimportAtClientfromat_client.commonimportAtSignfromat_client.common.keysimportPublicKeyatsign=AtSign("@bob")atclient=AtClient(atsign)pk=PublicKey("key",atsign)# Sending dataresponse=atclient.put(pk,"value")print(response)# Receiving Dataresponse=atclient.get(pk)print(response)# Deleting dataresponse=atclient.delete(pk)print(response)Using SelfKeyfromat_clientimportAtClientfromat_client.commonimportAtSignfromat_client.common.keysimportSelfKeyatsign=AtSign("@bob")atclient=AtClient(atsign)sk=SelfKey("key",atsign)# Sending dataresponse=atclient.put(sk,"value")print(response)# Receiving Dataresponse=atclient.get(sk)print(response)# Deleting dataresponse=atclient.delete(sk)print(response)Using SharedKeyfromat_clientimportAtClientfromat_client.commonimportAtSignfromat_client.common.keysimportSharedKeybob=AtSign("@bob")alice=AtSign("@alice")bob_atclient=AtClient(bob)sk=SharedKey("key",bob,alice)# Sending dataresponse=bob_atclient.put(sk,"value")print(response)# Receiving Dataalice_atclient=AtClient(alice)response=alice_atclient.get(sk)print(response)# Deleting dataresponse=bob_atclient.delete(sk)print(response)CLI ToolsREPL- you can use this to type atPlatform commands and see responses;
but the best thing about the REPL currently is that it shows the data
notifications as they are received. The REPL code has the essentials of what
a 'receiving' client needs to do - i.e.create an AtClient (assigning a Queue object to its queue parameter)start two new threadsone for the AtClient.start_monitor() task: receives data update/delete
notification events (the event data contains the ciphertext)the other one calls handle_event() method, which will read the
upcoming events in the queue and handle them:calling AtClient.handle_event() (to decrypt the notifications and
introducing the result as a new event in the queue)reading the new event, which contains the decrypted resultInstructions to run the REPL:Run repl.py and choose an atSign using option1Select option2. REPL will start and activate monitor mode
automatically in a different thread. You can still send commands/verbs.
You will start seeing your own notifications (from yourself to yourself)
and heartbeat working (noop verb is sent from time to time as a keepalive)Useat_talkor any other tool to send notifications to your atSign
from a different atSign. You should be able to see the complete
notification, and the encrypted and decrypted value of it.REGISTER- use this cli to register new free atsign. Uses onboarding
cli to create atkey files.Use following command to run the REGISTER cli using email:pythonregister.py-e<email>Use following command to run the REGISTER cli using api-key:pythonregister.py-k<api-key>ONBOARDING- use this cli to onboard a new atSign. Once onboarding
is complete it creates the all-important keys file. Onboard is a subset of
Register.Use following command to run the ONBOARDING cli:pythononboarding.py-a<atsign>-c<cram-secret>SHARE- use this cli to share data between 2 atsigns.Use following command to run the SHARE cli:pythonshare.py-a<atsign>-o<other-atsign>-k<key-name>-s<value>GET- use this cli to get shared data between 2 atsigns.Use following command to run the GET cli:pythonget.py-a<atsign>-o<other-atsign>-k<key-name>DELETE- use this cli to delete any key shared between 2 atsigns.Use following command to run the DELETE cli:pythondelete.py-a<atsign>-o<other-atsign>-k<key-name>Open source usage and contributionsThis is open source code, so feel free to use it as is, suggest changes or
enhancements or create your own version. SeeCONTRIBUTING.mdfor detailed guidance on how to setup
tools, tests and make a pull request.MaintainersThis project was created byUmang Shahand is maintained byChris SwanandXavier Lin