📜  cowin api (1)

📅  最后修改于: 2023-12-03 14:40:14.340000             🧑  作者: Mango

Cowin API

Cowin API is a free and open API provided by the Indian government to access real-time data of vaccination centers and slots availability in India. This API is available for all developers who want to build applications or services that help people find vaccination centers and slots.

API Endpoints

The Cowin API has three main endpoints that provide the data in JSON format.

1. States

This endpoint provides the list of all states in India along with their state ID. To access this endpoint, use the following URL:

https://cdn-api.co-vin.in/api/v2/admin/location/states

The response will be in the following format:

{
    "states": [
        {
            "state_id": 1,
            "state_name": "Andaman and Nicobar Islands"
        },
        {
            "state_id": 2,
            "state_name": "Andhra Pradesh"
        },
        // ... more states
    ]
}
2. Districts

This endpoint provides the list of all districts in a state, along with their district IDs. To access this endpoint, use the following URL:

https://cdn-api.co-vin.in/api/v2/admin/location/districts/<state_id>

Replace <state_id> with the state ID you want to get the districts for. For example, to get the districts for the state of Karnataka, you would use the following URL:

https://cdn-api.co-vin.in/api/v2/admin/location/districts/16

The response will be in the following format:

{
    "districts": [
        {
            "district_id": 265,
            "district_name": "Bagalkot"
        },
        {
            "district_id": 276,
            "district_name": "Ballari"
        },
        // ... more districts
    ]
}
3. Slots

This endpoint provides real-time data about the vaccination centers and slots availability. To access this endpoint, use the following URL:

https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=<district_id>&date=<date>

Replace <district_id> with the district ID you want to get the data for, and <date> with the date you want to get the data for (in the format DD-MM-YYYY). For example, to get the data for the district of Bangalore Urban on 10th June 2021, you would use the following URL:

https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=265&date=10-06-2021

The response will be in the following format:

{
    "centers": [
        {
            "center_id": 100001,
            "name": "Apollo Covid Vaccination",
            "address": "Apollo Hospital",
            "district_name": "Bangalore Urban",
            "state_name": "Karnataka",
            "fee_type": "Free",
            "sessions": [
                {
                    "session_id": "001",
                    "date": "10-06-2021",
                    "available_capacity": 10,
                    "min_age_limit": 18,
                    "vaccine": "COVISHIELD"
                },
                // ... more sessions
            ]
        },
        // ... more centers
    ]
}
Conclusion

Cowin API is a very useful tool for developers who want to build applications or services that help people find vaccination centers and slots. By using this API, you can access real-time data about vaccination centers and slots availability in India.