Skip to content

wynum/wynum-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

pip install wynum

To install using github try

pip install -U -e git+https://github.com/wynum/wynum-python#egg=wynum

Getting started

Very easy to use. Create a Client and you're ready to go.

API Credentials

The Client needs Wynum credentials.You can either pass these directly to the constructor.

from wynum import Client

secret = "your_secret_key"
token = "project_token"
client = Client(secret, token)

Get schema

call getschema on Client to get the keys and types for the data. This will return a list of Schema objects. Schema.key will return the key and Schema.type will return the Wynum type. Following is the mapping from Wynum type to python type.

Wynum type Python type
Text str
Date str (dd/mm/yyyy)
Number int or float
Choice (Or) int or float
Multiple Choice (And) list of str
Time str (hh:mm)
File File
schemas = client.getschema()
for schema in schemas:
    print(schema.key, schema.type)

Post data

the postdata method accepts a single parameter data which is dict containing the post key:value. Every data dict should contain the 'identifier'. You can get identifier key if you have called getschema. You can retrieve it using client.identifier.

client.getschema()
identifer_key = client.identifier
data = {'key1':val1, 'key2':val2, identifer_key:'id_string'}
res = client.postdata(data)

If the call is successful it returns the dict containing the created data instance. If there is some error the dict will contain _error and _message keys. You should check this to check for errors.

Get data

Call getdata to get the data. This will return list of dict. getdata accepts following keyword arguments

  • limit: int
    Number of records to return.
  • order_by: str
    Sorting order which can either be 'asc' or desc'
  • ids: list of str
    The list of ids to retrieve
  • start: int
    Record number to start from
  • to: int
    Record number to end at

start and to can be used for pagination.

If no arguments are provided it will return the list of all data records.

data = client.getdata()

Updating data

The update method is same as that of postdata method.

client.getschema()
identifer_key = client.identifier
data = {'key1':val1, 'key2':val2, identifer_key:'id_string'}
res = client.update(data)

Delete Data

The deletedata method can be used to delete a particular record. It accepts only single parameter

  • data: dict
    A dict containing the identifier as the key and the the id of the record that you want to delete as its value

for example if you want to delete a record with id jarvis and your unique identifier is id then

data = {'id': 'jarvis'}
client.deletedata(data)

Releases

No releases published

Packages

No packages published

Languages