Skip to main content

Device Magic API Wrapper

Project description

pydevice

Device Magic API Wrapper

Currently supports:

  • Device Magic Database
  • Destinations
  • Devices
  • Forms
  • Resources

Installation

pip install pydevice

Usage

>>> from pydevice import DeviceMagic
>>> args = {'org_id': 3000,'database_id': 580, 'form_id': 6000, 'resource_id': 103, 'file_path': 'path/to/file'}
>>> dm = DeviceMagic(args)
>>> dm.form.all() # destination, device, form, and resource also have this method
{'forms': [{'id': 40015631, 'name': 'Daily Report'...}

Authentication

Authentication is handled by the DeviceMagic class. The class can handle authentication automatically if the environment variable DEVICEMAGIC_API_KEY is set with your api key.

>>> dm = DeviceMagic(args)

In preference, you can pass the key explicitly:

>>> dm = DeviceMagic({'api_key': 'HTTP_Auth_Header_Value'})

Database

>>> dm.database.json()
{'per_page': 30, 'current_page': 1, 'total_pages': 1, 'current_count': 13, 'total_count': 13, 'submissions': [{'form'...
>>> dm.database.json("from_date=2018-5-1 00:00", "to_date=2018-5-31 00:00")
{...'total_count': 1, 'submissions': [{'form': {'id': 6009105, 'name': 'Sales Report'...}

Destination

>>> dm.destination.copy(26754)
'Destination created'

Optionally you can pass the id of a different form in which you'd like to copy the destination to.

>>> dm.destination.copy(26754, form_id=4008185)

Device

>>> dm.device.approve(2801)
'Device approved'

Form

>>> dm.form.details(3005)
{'type': 'root', 'children': [{'identifier': 'Yes_No_Question', 'title': 'Yes/No Question', 'autoIdentifier': True, 'type': 'boolean'}, {'identifier': 'Date_Question', 'title': 'Date Question', 'autoIdentifier': True, 'type': 'date'}...}

Resource

>>> dm.resource.update(480,'client_list', 'client_list.xlsx')
'Resource updated'

Official Device Magic API docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydevice-0.1.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

pydevice-0.1.0-py3-none-any.whl (10.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page