swisscoverage

The API

A public API, read-only, that serves as JSON the mobile network sites that OFCOM publishes, as they are today and as they were since the archive began. It is free, needs no key, and answers requests from any website.

Every address on this page starts with https://api.swisscoverage.ch.

The reference below is generated from the API's contract, openapi.json, and is written in English, as the contract is.

01A first request

Copy this command into a terminal: it lists the stations around a point, the nearest first.

curl -sS --compressed 'https://api.swisscoverage.ch/v1/stations/search?lat=46.948&lon=7.4474&radius=300'

02Source and terms

The data comes from the Federal Office of Communications OFCOM. Its terms of use ask that the source be given: every response that carries data has an attribution field, to show wherever the data is used.

OFCOM's terms of use, on opendata.swiss

The mobile network sites of Switzerland that OFCOM publishes, as they are today and as they were since the archive began. Read-only, and free to use. Source: Federal Office of Communications OFCOM, whose terms ask that the source be given: https://opendata.swiss/en/terms-of-use/#terms_by. Every response may be cached: the data changes once a day.

Version 1.0.0 of the contractAGPL-3.0-only, for the code; the data keeps the terms of its source

03Endpoints

GET/v1/snapshots

The snapshots

The files published by OFCOM that the data comes from, one per day since the archive began, the newest first.

Example

curl -sS --compressed 'https://api.swisscoverage.ch/v1/snapshots'

Parameters

  • limitintegerin the query

    The most items to return.

    • Default 100
    • At least 1
    • At most 1000
  • offsetintegerin the query

    How many items to skip, for the next pages.

    • Default 0
    • At least 0
    • At most 1000000

Responses

  • 200OKSnapshotListapplication/json
  • 304Not modified: the response named by If-None-Match is still the current one.
  • 422Unprocessable EntityErrorModelapplication/problem+json
  • 500Internal Server ErrorErrorModelapplication/problem+json
  • 503Service UnavailableErrorModelapplication/problem+json

GET/v1/stations

Every station published today

Every site of the latest snapshot, as one GeoJSON FeatureCollection, which is what the map loads. It is not paginated: the dataset bounds it, at about 23,000 sites. For a station's details, read it by its id.

Example

curl -sS --compressed 'https://api.swisscoverage.ch/v1/stations'

Responses

  • 200OKStationCollectionapplication/geo+json
  • 304Not modified: the response named by If-None-Match is still the current one.
  • 422Unprocessable EntityErrorModelapplication/problem+json
  • 500Internal Server ErrorErrorModelapplication/problem+json
  • 503Service UnavailableErrorModelapplication/problem+json

GET/v1/stations/{id}

One station and its history

A site, published today or in the past, with what each snapshot published about it: one period for each stretch of time during which nothing changed, the latest first.

Example

curl -sS --compressed 'https://api.swisscoverage.ch/v1/stations/2683328_1247916_Sunrise%20ZE416-1'

Parameters

  • idstringin the pathrequired

    The station's identifier, as east_north_label, such as 2683000_1247000_Sunrise ZH601-1, percent-encoded in the path.

    • Example 2683328_1247916_Sunrise ZE416-1
    • Up to 1000 characters
    • Matches ^-?[0-9]+(\.[0-9]+)?_-?[0-9]+(\.[0-9]+)?_[\s\S]+$
  • limitintegerin the query

    The most items to return.

    • Default 100
    • At least 1
    • At most 1000
  • offsetintegerin the query

    How many items to skip, for the next pages.

    • Default 0
    • At least 0
    • At most 1000000

Responses

  • 200OKStationHistoryapplication/json
  • 304Not modified: the response named by If-None-Match is still the current one.
  • 404Not FoundErrorModelapplication/problem+json
  • 422Unprocessable EntityErrorModelapplication/problem+json
  • 500Internal Server ErrorErrorModelapplication/problem+json
  • 503Service UnavailableErrorModelapplication/problem+json

GET/v1/stations/counts

Counts of stations

How many sites the latest snapshot publishes, in all and for each operator, kind, power class and technology. Every value is listed, with zero when no site has it. A site counts once for each of its technologies.

Example

curl -sS --compressed 'https://api.swisscoverage.ch/v1/stations/counts'

Responses

  • 200OKStationCountsapplication/json
  • 304Not modified: the response named by If-None-Match is still the current one.
  • 422Unprocessable EntityErrorModelapplication/problem+json
  • 500Internal Server ErrorErrorModelapplication/problem+json
  • 503Service UnavailableErrorModelapplication/problem+json

GET/v1/stations/search

Stations in a rectangle or around a point

The sites of the latest snapshot inside a rectangle, given by bbox, or within radius metres of a point, given by lat and lon. Exactly one of the two is required. Each filter accepts several values, separated by commas, and keeps the sites that have one of them; filters combine with each other. Results are ordered by label and position, or nearest first around a point.

Example

curl -sS --compressed 'https://api.swisscoverage.ch/v1/stations/search?lat=46.948&lon=7.4474&radius=300'

Parameters

  • bboxnumber[]in the query

    A rectangle in WGS84, as west,south,east,north in degrees: the longitude of its west edge, the latitude of its south edge, and so on. Edges are included.

    • Exactly 4 values
  • latnumberin the query

    The latitude of the point to search around, in WGS84 degrees. Requires lon.

    • Example 46.948
    • At least -90
    • At most 90
  • lonnumberin the query

    The longitude of the point to search around, in WGS84 degrees. Requires lat.

    • Example 7.4474
    • At least -180
    • At most 180
  • radiusnumberin the query

    Around a point: the distance to search within, in metres.

    • Default 1000
    • Example 300
    • At least 1
    • At most 50000
  • operatorstring[]in the query

    Keeps the sites run by one of these operators.

    Valuesswisscomsunrisesaltsbbother

    • Up to 5 values
  • kindstring[]in the query

    Keeps the sites of one of these kinds.

    Valuesoutdooroutdoor_low_powerindoortunneltemporaryunknown

    • Up to 6 values
  • powerClassstring[]in the query

    Keeps the sites of one of these power classes.

    Valuesvery_lowlowmediumhighunknown

    • Up to 5 values
  • technologystring[]in the query

    Keeps the sites that have one of these technologies.

    Values2G3G4G5G

    • Up to 4 values
  • limitintegerin the query

    The most items to return.

    • Default 100
    • At least 1
    • At most 1000
  • offsetintegerin the query

    How many items to skip, for the next pages.

    • Default 0
    • At least 0
    • At most 1000000

Responses

  • 200OKSearchResultapplication/json
  • 304Not modified: the response named by If-None-Match is still the current one.
  • 422Unprocessable EntityErrorModelapplication/problem+json
  • 500Internal Server ErrorErrorModelapplication/problem+json
  • 503Service UnavailableErrorModelapplication/problem+json

04Errors

A request that fails is answered with one of the statuses below and a body of type application/problem+json, whose fields are those of ErrorModel.

  • 404Not Found
  • 422Unprocessable Entity
  • 500Internal Server Error
  • 503Service Unavailable

ErrorModel

05Caching

  • Cache-Control

    The response may be reused for five minutes: the data changes once a day.

  • ETag

    Changes exactly when the response does. Send it back in If-None-Match to get 304 when nothing changed.

  • If-None-MatchRequest header

    The ETag of a response already held.

  • 304

    Not modified: the response named by If-None-Match is still the current one.

06Types

ErrorDetail

  • locationstring

    Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'

  • messagestring

    Error message text

  • valueany

    The value at the given location

ErrorModel

  • detailstring

    A human-readable explanation specific to this occurrence of the problem.

  • errorsErrorDetail[]

    Optional list of individual error details

  • instancestring (uri)

    A URI reference that identifies the specific occurrence of the problem.

  • statusinteger

    HTTP status code

  • titlestring

    A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

  • typestring (uri)

    A URI reference to human-readable documentation for the error.

    • Default about:blank

KindCount

  • stationsintegerrequired

    • At least 0
  • valuestringrequired

    The type of site: outdoor above 6 W ERP, outdoor up to 6 W ERP, indoor up to 6 W ERP, in a tunnel, temporary, or not published.

    Valuesoutdooroutdoor_low_powerindoortunneltemporaryunknown

LV95

  • eastnumberrequired

    Easting in LV95 (EPSG:2056), in metres.

  • northnumberrequired

    Northing in LV95 (EPSG:2056), in metres.

OperatorCount

  • stationsintegerrequired

    • At least 0
  • valuestringrequired

    Who runs the station. other groups the stations published without a known operator, such as foreign stations near the border.

    Valuesswisscomsunrisesaltsbbother

Period

  • adaptiveboolean | nullrequired

    Whether at least part of the site runs adaptive antennas. Null when the file says something that is not recognised.

  • fromstring (date-time)required

    The publication time of the snapshot that first showed these values.

  • installationLimitValuenumber | nullrequired

    The installation limit value, in V/m. Null when absent or left blank.

  • kindstringrequired

    The type of site: outdoor above 6 W ERP, outdoor up to 6 W ERP, indoor up to 6 W ERP, in a tunnel, temporary, or not published.

    Valuesoutdooroutdoor_low_powerindoortunneltemporaryunknown

  • permitPermit | nullrequired

    Null when OFCOM publishes no permit information.

  • powerClassstringrequired

    The class of ERP90, the highest cumulated power radiated in a 90° sector, as OFCOM publishes it.

    Valuesvery_lowlowmediumhighunknown

  • technologiesstring[]required

    In generation order. Empty when the file lists none that is recognised.

    Values2G3G4G5G

  • tostring (date-time) | nullrequired

    The publication time of the first snapshot that no longer did. Null while they are still published.

Permit

  • typestringrequired

    site_data_sheet: a site data sheet was filed. exempt: the site is exempt from the precautionary emission limit (NISV Annex 1 No. 64).

    Valuessite_data_sheetexempt

  • datestring (date)

    The date of the site data sheet. Absent for an exemption, and when the published date is not a day that exists.

PointGeometry

  • coordinatesnumber[]required

    Longitude and latitude in WGS84, in degrees, to 7 decimals.

    • Exactly 2 values
  • typestringrequired

    ValuesPoint

Position

  • latnumberrequired

    Latitude in WGS84, in degrees.

    • At least -90
    • At most 90
  • lonnumberrequired

    Longitude in WGS84, in degrees.

    • At least -180
    • At most 180

PowerClassCount

  • stationsintegerrequired

    • At least 0
  • valuestringrequired

    The class of ERP90, the highest cumulated power radiated in a 90° sector, as OFCOM publishes it.

    Valuesvery_lowlowmediumhighunknown

PublishedStation

  • adaptiveboolean | nullrequired

    Whether at least part of the site runs adaptive antennas. Null when the file says something that is not recognised.

  • codestringrequired

    The label without the operator's name, such as "ZH601-1".

  • firstSeenstring (date-time)required

    The publication time of the first snapshot that showed the site.

  • idstringrequired

    The site's identifier: its LV95 position and its label, as east_north_label. OFCOM publishes no identifier, and a label alone is not unique.

  • installationLimitValuenumber | nullrequired

    The installation limit value, in V/m. Null when absent or left blank.

  • kindstringrequired

    The type of site: outdoor above 6 W ERP, outdoor up to 6 W ERP, indoor up to 6 W ERP, in a tunnel, temporary, or not published.

    Valuesoutdooroutdoor_low_powerindoortunneltemporaryunknown

  • lv95LV95required

    The position as published.

  • namestringrequired

    The station label exactly as published, such as "Sunrise ZH601-1".

  • operatorstringrequired

    Who runs the station. other groups the stations published without a known operator, such as foreign stations near the border.

    Valuesswisscomsunrisesaltsbbother

  • permitPermit | nullrequired

    Null when OFCOM publishes no permit information.

  • positionPositionrequired

    The same position in WGS84, computed with the rigorous transformation, to 7 decimals.

  • powerClassstringrequired

    The class of ERP90, the highest cumulated power radiated in a 90° sector, as OFCOM publishes it.

    Valuesvery_lowlowmediumhighunknown

  • technologiesstring[]required

    In generation order. Empty when the file lists none that is recognised.

    Values2G3G4G5G

  • distancenumber

    Around a point only: the distance from it, in metres, on the ellipsoid.

SearchResult

  • attributionstringrequired

    The credit OFCOM's terms require.

  • limitintegerrequired

  • offsetintegerrequired

  • snapshotSnapshotrequired

    The snapshot these stations come from.

  • stationsPublishedStation[]required

  • totalintegerrequired

    How many stations the search matched, on every page.

Snapshot

  • publishedAtstring (date-time)required

    When OFCOM published the file. It identifies the snapshot.

  • sha256stringrequired

    The SHA-256 of the file as published, in hexadecimal.

    • Matches ^[0-9a-f]{64}$
  • sitesintegerrequired

    The number of sites in the file.

    • At least 0

SnapshotList

  • attributionstringrequired

    The credit OFCOM's terms require.

  • limitintegerrequired

  • offsetintegerrequired

  • snapshotsSnapshot[]required

    The newest first.

  • totalintegerrequired

    How many snapshots there are, on every page.

StationCollection

  • attributionstringrequired

    The credit OFCOM's terms require.

  • featuresStationFeature[]required

  • snapshotSnapshotrequired

    The snapshot these stations come from.

  • typestringrequired

    ValuesFeatureCollection

StationFeature

  • geometryPointGeometryrequired

  • idstringrequired

    The station's identifier, as in the station's own response.

  • propertiesStationPropertiesrequired

  • typestringrequired

    ValuesFeature

StationHistory

  • attributionstringrequired

    The credit OFCOM's terms require.

  • codestringrequired

    The label without the operator's name, such as "ZH601-1".

  • firstSeenstring (date-time)required

    The publication time of the first snapshot that showed the site.

  • idstringrequired

    The site's identifier: its LV95 position and its label, as east_north_label. OFCOM publishes no identifier, and a label alone is not unique.

  • limitintegerrequired

  • lv95LV95required

    The position as published.

  • namestringrequired

    The station label exactly as published, such as "Sunrise ZH601-1".

  • offsetintegerrequired

  • operatorstringrequired

    Who runs the station. other groups the stations published without a known operator, such as foreign stations near the border.

    Valuesswisscomsunrisesaltsbbother

  • periodsPeriod[]required

    What was published of the site, period by period, the latest first.

  • positionPositionrequired

    The same position in WGS84, computed with the rigorous transformation, to 7 decimals.

  • publishedbooleanrequired

    Whether the latest snapshot shows the site.

  • totalintegerrequired

    How many periods the site has, on every page.

StationProperties

  • kindstringrequired

    The type of site: outdoor above 6 W ERP, outdoor up to 6 W ERP, indoor up to 6 W ERP, in a tunnel, temporary, or not published.

    Valuesoutdooroutdoor_low_powerindoortunneltemporaryunknown

  • namestringrequired

    The station label exactly as published.

  • operatorstringrequired

    Who runs the station. other groups the stations published without a known operator, such as foreign stations near the border.

    Valuesswisscomsunrisesaltsbbother

  • powerClassstringrequired

    The class of ERP90, the highest cumulated power radiated in a 90° sector, as OFCOM publishes it.

    Valuesvery_lowlowmediumhighunknown

  • technologiesstring[]required

    In generation order. Empty when the file lists none that is recognised.

    Values2G3G4G5G

TechnologyCount

  • stationsintegerrequired

    • At least 0
  • valuestringrequired

    A mobile network generation.

    Values2G3G4G5G

07The contract

The whole API is described in OpenAPI 3.1, in a file that the API serves and that the repository keeps. Clients can be generated from it.