Skip to main content

Interact with CoWin APIs

Project description

Cowin API

Python package to interact with COWIN Public API

Features

  • Supports both Synchronous and Asynchronous modes.
  • 95% test coverage with mocking API responses.
  • Get list of states
  • Get list of districts for a state
  • Generate and Verify OTP
  • Download Certificates

Example:

For API response payload samples visit the API portal.

# blocking synchronous client
from cowin import Cowin

client = Cowin()

states = client.get_states()
districts = client.get_districts(state_id=4)

# below function accepts optional datetime.date object
# by default current date is used
vaccine_sessions = client.get_sessions_by_pincode(pincode='605001')

# get OTP to mobile number
response = client.get_otp(mobile='9876543210')
txn_id = response['txnId']

# verify OTP and receive token
response = client.confirm_otp(txn_id=txn_id, otp='123456')
token = response['token']
# non-blocking async client
from cowin import AsyncCowin

async_client = AsyncCowin()

states = await async_client.get_stateS()
districts = await async_client.get_districts(state_id=4)

vaccine_sessions = await async_client.get_sessions_by_pincode(pincode='605001')

# get OTP to mobile number
response = await async_client.get_otp(mobile='9876543210')
txn_id = response['txnId']

# verify OTP and receive token
response = await async_client.confirm_otp(txn_id=txn_id, otp='123456')
token = response['token']

Contributions

Issues and pull requests are welcome. Feel free to improve the package.

License:

LGPL v3.0

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

cowin-async-1.0.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

cowin_async-1.0-py3-none-any.whl (14.5 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