swisscoverage

L’API

Une API publique, en lecture seule, qui sert en JSON les sites de téléphonie mobile que l’OFCOM publie, tels qu’ils sont aujourd’hui et tels qu’ils étaient depuis le début de l’archive. Elle est gratuite, ne demande aucune clé et répond aux requêtes de n’importe quel site web.

Chaque adresse de cette page commence par https://api.swisscoverage.ch.

La référence ci-dessous est générée à partir du contrat de l’API, openapi.json, et elle est rédigée en anglais, comme le contrat.

01Une première requête

Copiez cette commande dans un terminal : elle liste les stations autour d’un point, de la plus proche à la plus éloignée.

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

02Source et conditions

Les données viennent de l’Office fédéral de la communication OFCOM. Ses conditions d’utilisation demandent que la source soit indiquée : chaque réponse qui contient des données a un champ attribution, à afficher partout où les données sont utilisées.

Les conditions d’utilisation de l’OFCOM, sur 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 du contratAGPL-3.0-only, for the code; the data keeps the terms of its source

03Points d’accès

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.

Exemple

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

Paramètres

  • limitintegerdans la requête

    The most items to return.

    • Par défaut 100
    • Au moins 1
    • Au plus 1000
  • offsetintegerdans la requête

    How many items to skip, for the next pages.

    • Par défaut 0
    • Au moins 0
    • Au plus 1000000

Réponses

  • 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.

Exemple

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

Réponses

  • 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.

Exemple

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

Paramètres

  • idstringdans le cheminobligatoire

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

    • Exemple 2683328_1247916_Sunrise ZE416-1
    • Jusqu’à 1000 caractères
    • Correspond à ^-?[0-9]+(\.[0-9]+)?_-?[0-9]+(\.[0-9]+)?_[\s\S]+$
  • limitintegerdans la requête

    The most items to return.

    • Par défaut 100
    • Au moins 1
    • Au plus 1000
  • offsetintegerdans la requête

    How many items to skip, for the next pages.

    • Par défaut 0
    • Au moins 0
    • Au plus 1000000

Réponses

  • 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.

Exemple

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

Réponses

  • 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.

Exemple

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

Paramètres

  • bboxnumber[]dans la requête

    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.

    • Exactement 4 valeurs
  • latnumberdans la requête

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

    • Exemple 46.948
    • Au moins -90
    • Au plus 90
  • lonnumberdans la requête

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

    • Exemple 7.4474
    • Au moins -180
    • Au plus 180
  • radiusnumberdans la requête

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

    • Par défaut 1000
    • Exemple 300
    • Au moins 1
    • Au plus 50000
  • operatorstring[]dans la requête

    Keeps the sites run by one of these operators.

    Valeursswisscomsunrisesaltsbbother

    • Jusqu’à 5 valeurs
  • kindstring[]dans la requête

    Keeps the sites of one of these kinds.

    Valeursoutdooroutdoor_low_powerindoortunneltemporaryunknown

    • Jusqu’à 6 valeurs
  • powerClassstring[]dans la requête

    Keeps the sites of one of these power classes.

    Valeursvery_lowlowmediumhighunknown

    • Jusqu’à 5 valeurs
  • technologystring[]dans la requête

    Keeps the sites that have one of these technologies.

    Valeurs2G3G4G5G

    • Jusqu’à 4 valeurs
  • limitintegerdans la requête

    The most items to return.

    • Par défaut 100
    • Au moins 1
    • Au plus 1000
  • offsetintegerdans la requête

    How many items to skip, for the next pages.

    • Par défaut 0
    • Au moins 0
    • Au plus 1000000

Réponses

  • 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

04Erreurs

Une requête qui échoue reçoit l’un des statuts ci-dessous et un corps de type application/problem+json, dont les champs sont ceux de ErrorModel.

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

ErrorModel

05Cache

  • 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-MatchEn-tête de la requête

    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.

    • Par défaut about:blank

KindCount

  • stationsintegerobligatoire

    • Au moins 0
  • valuestringobligatoire

    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.

    Valeursoutdooroutdoor_low_powerindoortunneltemporaryunknown

LV95

  • eastnumberobligatoire

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

  • northnumberobligatoire

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

OperatorCount

  • stationsintegerobligatoire

    • Au moins 0
  • valuestringobligatoire

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

    Valeursswisscomsunrisesaltsbbother

Period

  • adaptiveboolean | nullobligatoire

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

  • fromstring (date-time)obligatoire

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

  • installationLimitValuenumber | nullobligatoire

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

  • kindstringobligatoire

    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.

    Valeursoutdooroutdoor_low_powerindoortunneltemporaryunknown

  • permitPermit | nullobligatoire

    Null when OFCOM publishes no permit information.

  • powerClassstringobligatoire

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

    Valeursvery_lowlowmediumhighunknown

  • technologiesstring[]obligatoire

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

    Valeurs2G3G4G5G

  • tostring (date-time) | nullobligatoire

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

Permit

  • typestringobligatoire

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

    Valeurssite_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[]obligatoire

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

    • Exactement 2 valeurs
  • typestringobligatoire

    ValeursPoint

Position

  • latnumberobligatoire

    Latitude in WGS84, in degrees.

    • Au moins -90
    • Au plus 90
  • lonnumberobligatoire

    Longitude in WGS84, in degrees.

    • Au moins -180
    • Au plus 180

PowerClassCount

  • stationsintegerobligatoire

    • Au moins 0
  • valuestringobligatoire

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

    Valeursvery_lowlowmediumhighunknown

PublishedStation

  • adaptiveboolean | nullobligatoire

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

  • codestringobligatoire

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

  • firstSeenstring (date-time)obligatoire

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

  • idstringobligatoire

    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 | nullobligatoire

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

  • kindstringobligatoire

    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.

    Valeursoutdooroutdoor_low_powerindoortunneltemporaryunknown

  • lv95LV95obligatoire

    The position as published.

  • namestringobligatoire

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

  • operatorstringobligatoire

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

    Valeursswisscomsunrisesaltsbbother

  • permitPermit | nullobligatoire

    Null when OFCOM publishes no permit information.

  • positionPositionobligatoire

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

  • powerClassstringobligatoire

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

    Valeursvery_lowlowmediumhighunknown

  • technologiesstring[]obligatoire

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

    Valeurs2G3G4G5G

  • distancenumber

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

SearchResult

  • attributionstringobligatoire

    The credit OFCOM's terms require.

  • limitintegerobligatoire

  • offsetintegerobligatoire

  • snapshotSnapshotobligatoire

    The snapshot these stations come from.

  • stationsPublishedStation[]obligatoire

  • totalintegerobligatoire

    How many stations the search matched, on every page.

Snapshot

  • publishedAtstring (date-time)obligatoire

    When OFCOM published the file. It identifies the snapshot.

  • sha256stringobligatoire

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

    • Correspond à ^[0-9a-f]{64}$
  • sitesintegerobligatoire

    The number of sites in the file.

    • Au moins 0

SnapshotList

  • attributionstringobligatoire

    The credit OFCOM's terms require.

  • limitintegerobligatoire

  • offsetintegerobligatoire

  • snapshotsSnapshot[]obligatoire

    The newest first.

  • totalintegerobligatoire

    How many snapshots there are, on every page.

StationCollection

  • attributionstringobligatoire

    The credit OFCOM's terms require.

  • featuresStationFeature[]obligatoire

  • snapshotSnapshotobligatoire

    The snapshot these stations come from.

  • typestringobligatoire

    ValeursFeatureCollection

StationCounts

  • attributionstringobligatoire

    The credit OFCOM's terms require.

  • kindsKindCount[]obligatoire

  • operatorsOperatorCount[]obligatoire

  • powerClassesPowerClassCount[]obligatoire

  • snapshotSnapshotobligatoire

    The snapshot these counts come from.

  • stationsintegerobligatoire

    How many sites the snapshot publishes.

    • Au moins 0
  • technologiesTechnologyCount[]obligatoire

StationFeature

  • geometryPointGeometryobligatoire

  • idstringobligatoire

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

  • propertiesStationPropertiesobligatoire

  • typestringobligatoire

    ValeursFeature

StationHistory

  • attributionstringobligatoire

    The credit OFCOM's terms require.

  • codestringobligatoire

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

  • firstSeenstring (date-time)obligatoire

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

  • idstringobligatoire

    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.

  • limitintegerobligatoire

  • lv95LV95obligatoire

    The position as published.

  • namestringobligatoire

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

  • offsetintegerobligatoire

  • operatorstringobligatoire

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

    Valeursswisscomsunrisesaltsbbother

  • periodsPeriod[]obligatoire

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

  • positionPositionobligatoire

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

  • publishedbooleanobligatoire

    Whether the latest snapshot shows the site.

  • totalintegerobligatoire

    How many periods the site has, on every page.

StationProperties

  • kindstringobligatoire

    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.

    Valeursoutdooroutdoor_low_powerindoortunneltemporaryunknown

  • namestringobligatoire

    The station label exactly as published.

  • operatorstringobligatoire

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

    Valeursswisscomsunrisesaltsbbother

  • powerClassstringobligatoire

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

    Valeursvery_lowlowmediumhighunknown

  • technologiesstring[]obligatoire

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

    Valeurs2G3G4G5G

TechnologyCount

  • stationsintegerobligatoire

    • Au moins 0
  • valuestringobligatoire

    A mobile network generation.

    Valeurs2G3G4G5G

07Le contrat

Toute l’API est décrite en OpenAPI 3.1, dans un fichier que l’API sert et que le dépôt conserve. On peut en générer des clients.