chargelk-api-v1.openapi.json 17.9 KB Download Raw
{
  "openapi": "3.0.3",
  "info": {
    "title": "ChargeLK charging station API",
    "version": "1.0.0",
    "description": "Real-time availability, location, facilities and prices of ChargeLK EV chargers in Sri Lanka, for navigation and fleet software. Read only. No customer data. ChargeLK is operated by CMS Techno Solutions."
  },
  "servers": [
    {
      "url": "https://chargelk.com/api/v1"
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Stations",
      "description": "A site with one or more chargers."
    },
    {
      "name": "Chargers",
      "description": "One charger on its own."
    }
  ],
  "paths": {
    "/stations": {
      "get": {
        "summary": "List stations with their chargers",
        "description": "A station is a site with one or more chargers. Give \"near\" to get the closest first, each with distance_km.",
        "parameters": [
          {
            "name": "near",
            "in": "query",
            "description": "A point as \"lat,lng\", for example 6.9271,79.8612. Returns stations within radius_km, nearest first.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "radius_km",
            "in": "query",
            "description": "Used with near. Default 25.",
            "schema": {
              "type": "number",
              "minimum": 0.1,
              "maximum": 500
            }
          },
          {
            "name": "city",
            "in": "query",
            "description": "Only stations in this city, spelled as in the data.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Only chargers with this status. Stations with no matching charger are left out.",
            "schema": {
              "type": "string",
              "enum": [
                "available",
                "occupied",
                "offline",
                "faulted",
                "maintenance"
              ]
            }
          },
          {
            "name": "connector",
            "in": "query",
            "description": "Only chargers with this connector.",
            "schema": {
              "type": "string",
              "enum": [
                "CCS2",
                "CHAdeMO",
                "GBT",
                "Type2"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Which page of results. 1 is the first.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "description": "How many stations on a page, up to 200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 100
            }
          }
        ],
        "tags": [
          "Stations"
        ],
        "responses": {
          "200": {
            "description": "Stations and their chargers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationList"
                },
                "example": {
                  "data": [
                    {
                      "id": 12,
                      "name": "Galle Face Car Park",
                      "address": "1 Galle Road, Colombo 3",
                      "city": "Colombo",
                      "location": {
                        "lat": 6.9271,
                        "lng": 79.8438
                      },
                      "opening_hours": "Daily 06:00 to 22:00",
                      "amenities": [
                        "seating",
                        "washrooms",
                        "wifi"
                      ],
                      "distance_km": 1.4,
                      "chargers": [
                        {
                          "id": "CP-001",
                          "status": "available",
                          "status_checked_at": "2026-11-02T09:14:52+00:00",
                          "connector": {
                            "type": "CCS2",
                            "current": "DC",
                            "count": 1
                          },
                          "power_kw": 30,
                          "price": {
                            "currency": "LKR",
                            "per_kwh": {
                              "lkr": 100,
                              "cents": 10000
                            },
                            "idle_fee_per_minute": {
                              "lkr": 0,
                              "cents": 0
                            },
                            "tax_included": true
                          },
                          "planned_outage": null
                        }
                      ]
                    }
                  ],
                  "meta": {
                    "total": 1,
                    "page": 1,
                    "per_page": 100,
                    "generated_at": "2026-11-02T09:15:01+00:00"
                  }
                }
              }
            }
          },
          "422": {
            "description": "A parameter is not valid."
          },
          "401": {
            "description": "The API key is missing, wrong, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "This key has used up its requests for the minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/stations/{id}": {
      "get": {
        "summary": "One station",
        "tags": [
          "Stations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "example": 12,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The station and its chargers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationOne"
                },
                "example": {
                  "data": {
                    "id": 12,
                    "name": "Galle Face Car Park",
                    "address": "1 Galle Road, Colombo 3",
                    "city": "Colombo",
                    "location": {
                      "lat": 6.9271,
                      "lng": 79.8438
                    },
                    "opening_hours": "Daily 06:00 to 22:00",
                    "amenities": [
                      "seating",
                      "washrooms",
                      "wifi"
                    ],
                    "chargers": [
                      {
                        "id": "CP-001",
                        "status": "available",
                        "status_checked_at": "2026-11-02T09:14:52+00:00",
                        "connector": {
                          "type": "CCS2",
                          "current": "DC",
                          "count": 1
                        },
                        "power_kw": 30,
                        "price": {
                          "currency": "LKR",
                          "per_kwh": {
                            "lkr": 100,
                            "cents": 10000
                          },
                          "idle_fee_per_minute": {
                            "lkr": 0,
                            "cents": 0
                          },
                          "tax_included": true
                        },
                        "planned_outage": null
                      }
                    ]
                  },
                  "meta": {
                    "generated_at": "2026-11-02T09:15:01+00:00"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such station."
          },
          "401": {
            "description": "The API key is missing, wrong, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "This key has used up its requests for the minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chargers/{id}": {
      "get": {
        "summary": "One charger by its id",
        "tags": [
          "Chargers"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The charger id, for example CP-001.",
            "example": "CP-001",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The charger, with station_id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChargerOne"
                },
                "example": {
                  "data": {
                    "id": "CP-001",
                    "status": "available",
                    "status_checked_at": "2026-11-02T09:14:52+00:00",
                    "connector": {
                      "type": "CCS2",
                      "current": "DC",
                      "count": 1
                    },
                    "power_kw": 30,
                    "price": {
                      "currency": "LKR",
                      "per_kwh": {
                        "lkr": 100,
                        "cents": 10000
                      },
                      "idle_fee_per_minute": {
                        "lkr": 0,
                        "cents": 0
                      },
                      "tax_included": true
                    },
                    "planned_outage": null,
                    "station_id": 12
                  },
                  "meta": {
                    "generated_at": "2026-11-02T09:15:01+00:00"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such charger."
          },
          "401": {
            "description": "The API key is missing, wrong, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "This key has used up its requests for the minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your key, as \"Authorization: Bearer clk_...\". \"X-Api-Key: clk_...\" works too."
      }
    },
    "schemas": {
      "Money": {
        "type": "object",
        "properties": {
          "lkr": {
            "type": "number",
            "example": 100,
            "description": "Rupees, with decimals."
          },
          "cents": {
            "type": "integer",
            "example": 10000,
            "description": "Whole cents, for exact arithmetic."
          }
        }
      },
      "Charger": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "CP-001"
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "occupied",
              "offline",
              "faulted",
              "maintenance"
            ],
            "description": "A live reading, not a forecast."
          },
          "status_checked_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the charger last spoke to ChargeLK."
          },
          "connector": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "CCS2",
                  "CHAdeMO",
                  "GBT",
                  "Type2"
                ]
              },
              "current": {
                "type": "string",
                "enum": [
                  "AC",
                  "DC"
                ]
              },
              "count": {
                "type": "integer"
              }
            }
          },
          "power_kw": {
            "type": "integer",
            "description": "The most the charger can deliver."
          },
          "price": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "example": "LKR"
              },
              "per_kwh": {
                "$ref": "#/components/schemas/Money"
              },
              "idle_fee_per_minute": {
                "$ref": "#/components/schemas/Money"
              },
              "tax_included": {
                "type": "boolean"
              }
            }
          },
          "planned_outage": {
            "type": "object",
            "nullable": true,
            "properties": {
              "starts_at": {
                "type": "string",
                "format": "date-time"
              },
              "ends_at": {
                "type": "string",
                "format": "date-time"
              },
              "active": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "Station": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 12
          },
          "name": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "location": {
            "type": "object",
            "properties": {
              "lat": {
                "type": "number"
              },
              "lng": {
                "type": "number"
              }
            }
          },
          "opening_hours": {
            "type": "string",
            "nullable": true
          },
          "amenities": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "seating",
                "washrooms",
                "food",
                "wifi",
                "shelter",
                "security",
                "accessible"
              ]
            }
          },
          "distance_km": {
            "type": "number",
            "description": "Only when \"near\" was given."
          },
          "chargers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Charger"
            }
          }
        }
      },
      "StationList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Station"
            }
          },
          "meta": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "page": {
                "type": "integer"
              },
              "per_page": {
                "type": "integer"
              },
              "generated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "StationOne": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Station"
          },
          "meta": {
            "type": "object",
            "properties": {
              "generated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "ChargerOne": {
        "type": "object",
        "properties": {
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Charger"
              },
              {
                "type": "object",
                "properties": {
                  "station_id": {
                    "type": "integer"
                  }
                }
              }
            ]
          },
          "meta": {
            "type": "object",
            "properties": {
              "generated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "example": "invalid_api_key"
          }
        }
      }
    }
  }
}

Use it

  • Postman: Import, then paste the address https://chargelk.com/api/v1/openapi.json, or upload the downloaded file.
  • Insomnia: Create, Import, From URL, with the same address.
  • Swagger UI or Swagger Editor: paste the file, or open it from the address.
  • A client in your language: npx @openapitools/openapi-generator-cli generate -i chargelk-api-v1.openapi.json -g typescript-fetch -o client (other generators: python, php, java, go).

Every request needs your key, sent as Authorization: Bearer clk_.... The file itself is public and needs no key.

Chat on WhatsApp