Med detta API kan du reseplanera med hela Sveriges kollektivtrafik. APIet bygger på ResRobot som du hittar på resrobot.se. Reseplaneraren ResRobot är den mest kompletta Internetbaserade tjänsten för planering av resor inom Sverige. Här finns på ett och samma ställe tidtabeller för alla tåg, bussar, flyg, tunnelbanor och spårvagnar i landet samt vägbeskrivningar för bil. ResRobot innehåller även kartor över byten och gångvägar samt detaljerad stationsinformation. ResRobot gör det möjligt att enkelt jämföra resealternativ och i detalj planera resan från dörr till dörr.
I vårt API finns tyvärr inte flyg- och vägtrafik med av upphovsrättsliga skäl. Vi har inte heller någon koppling till stationsinfo.se, med detaljerad infomation om stationer i Sverige, på plats ännu. APIet stödjer reseplanering både med hållplatsnamn och med koordinater. Aktuell version är 2.1 (vilket anges i anropet).
API dokumentationen är helt på engelska.
This API uses UTF-8 as encoding for both parameters and responses. Due to an known error, the header of the response may say it ISO-8859-1. Please force UTF-8.
Super and Standard Versions
The ResRobot API exists in 2 versions that have the same methods functions in almost the same way. The difference between the Standard Version and the Super Version is that the former gets data from a database with stored time table data and the latter gets data in real time. This makes the Super Version more accurate but slower than the Standard Version. For the exact URLs used to call the Standard and Super version of the API see the individual API methods listed below.
XML or JSON, specified via suffix or the Accept header. The default format is XML if no format is specified.
Det krävs en giltig API nyckel som skickas med som parametern "key" i alla metodanrop. En API nyckel får man genom att skapa ett projekt som använder detta API. Mer om hur du skapar och använder API nycklar hittar du här. För att få en API nyckel så måste man godkänna APIets licensvillkor.
Det finns vissa begränsningar på antalet anrop per minut och per månad.
|Nivå||Max anrop/månad||Max anrop/minut|
|Vår målsättning är att alla som vill ha data ska få tillgång till denna, och att det ska förbli kostnadsfritt. Begränsningarna vi har idag är till för att vi vill kunna garantera att vår teknik fungerar till så många så möjligt. Innan vi uppgraderar en tjänst vill vi ha en prognos för hur mycket trafik tjänsten kommer att generera i relation till hur många resenärer som får nytta av informationen. För att få ditt konto uppgraderat, skicka ett e-post till email@example.com och berätta på vad du tänkt göra och hur din tjänst gör det lättare att resa kollektivt.|
- Search - find one or several trips.
- StationsInZone - search for stations in the vicinity of a geographic location.
- TimeTablePeriod - retrieve the start and end date of the current timetable period
- ProducerList - get a list of all the producers that are used in the system
- TransportModeList - get a list of all the possible transport modes that are being used in the system.
- FindLocation - find stations and/or addresses that match a search string
In the ResRobot API coordinates are specified using X and Y values. Those should be used and interpreted as follows:
X = Easting in RT90. In Sweden the value is something like 1500000.
Y = Northing in RT90. In Sweden the value is something like 6700000.
X = Longitude in WGS84. In Sweden the value is something like 15.
Y = Latitude in WGS84. In Sweden the value is something like 60.
In case a request is incorrect or cannot be completed, then the ResRobot API will return an error structure in the XML-result. If that structure is returned, then the ordinary XML-structure will not be returned at all. The result contains a structure <errors> that may contain several sub-structures <error>. The element <errorcode> contains an error code that the calling system can interpret according to the table below.
Mandatory parameter is missing
Invalid username or password
Unknown coordinate system
Invalid date or time
Invalid boolean value
Invalid location id
Invalid value for walking speed
Parameter from or to is too short
Request: https://api.trafiklab.se/samtrafiken/resrobot/StationsInZone?key=[YOUR API KEY]&apiVersion=2.1
Terms and conditions for Trafiklab.se APIs
Thank you for your interest in the Trafiklab.se API: s. The Trafiklab.se API: s (“ the API: s”) are a collection of API: s to data on public transportation in Sweden (“ the Provided Data”), collected and compiled by Samtrafiken i Sverige Aktiebolag (“ Samtrafiken”) and its partners, provided to you by Samtrafiken for the purpose of encouraging the development of applications, web services and similar developments related to public transportation in Sweden.
Provided that you
- register an account with Trafiklab.se at www.trafiklab.se;
- choose the type of API which best fits the purposes of your intended development (for detailed information on the technical requirements and limitations of each API type, see the technical documentation provided with each respective type of API) ; and
- click to accept these Terms and Conditions below;
trafiken grants you a license to the API of your choice in accordance with the following.
Subject to the terms and restrictions set forth in these Terms and Conditions, Samtrafiken grants you a worldwide, non-exclusive, non-transferable, non-assignable license to the API, for the purpose of accessing, using and publicly displaying the Provided Data in your application, web server or similar development.
The license is based on the principles of the Creative Commons Attribution-license, and thus allows you to share (copy, distribute and transmit the work) and remix (i. e. alter, adapt and change the work, including integration with other information and/or settings), also for commercial purposes, however provided that you attribute the work as specified in section 4.1 below. Conditions and limitations in addition to the Creative Commons Attribution-license also apply, as provided in these Terms and Conditions.
Said license, or any development based thereon, shall in no way be construed as a limitation of Samtrafiken’ s and its original sources’ right to freely utilize, develop or delete the API, the Provided Data or products or services based thereon.
In order to secure the availability and performance of the API and the Provided Data, developments based on the API shall be constructed in a manner which minimizes the capacity burden of the API. For this purpose, certain technical requirements and limitations are provided in the technical documentation of each type of API (“ the Technical Documentation”). The Technical Documentation shall be considered an integral part of these Terms and Conditions and, thus, by agreeing to accept these Terms and Conditions you agree to observe the limitations set forth in the Technical Documentation provided for the API of your choice.
Certain technical limitations, such as the number of requests per minute or month, may be improved by reserving a premium account. The prerequisites, terms and conditions for a premium account are stated in the respective Technical Documentation. Changes to other technical limitations, such as technical support, are only provided upon specific agreement with Samtrafiken. Such individual agreements may be discussed and arranged by contacting Samtrafiken at firstname.lastname@example.org.
Data requests in excess of or otherwise in breach of the technical limitations provided in the respective Technical Documentation may be blocked by Samtrafiken, and Samtrafiken reserves the right to terminate such license to the API in accordance with section 10 below.
Requirements on use
Applications, web services and similar developments which contain information retrieved via the API shall expressly state that the product or service is based on information retrieved from Trafiklab.se and, when practicable, a hyperlink to Trafiklab.se shall be provided.
Unless previously approved in writing by Samtrafiken, the API may not be used for applications, web services or similar developments which offer users the possibility to purchase tickets for public transportation. The approval of such functionality may however be discussed and agreed by contacting Samtrafiken at email@example.com.
As a condition for using and embedding the API into your application, web service or similar development you further agree that when using the API, you will not:
- copy Provided Data in order to create your own transcript of the Provided Data (the prohibition against copying does, however, not apply to temporary copies for the purpose of caching). Provided Data must always be retrieved via the API;
- assign, transfer or disclose the API key to any third party;
- interfere with, intercept, disrupt, filter or disable any features of the API or the Provided Data;
- transmit any viruses, worms, defects, Trojan horses or any such items of a destructive nature;
- infringe any third party intellectual property rights;
- access or use the API or any Provided Data through any technology or means other than those provided through Trafiklab.se;
- use the API or the Provided Data in a manner which directly or indirectly opposes or obstructs the purpose of Trafiklab.se and of Samtrafiken, i.e. to increase the lawful use of public transportation in Sweden;
- use the API or the Provided Data in a manner which in Samtrafiken’ s reasonable opinion disparages, infringes or dilutes the name, trademarks, logos, domain names and other distinctive brand features of Samtrafiken or its partners;
- use the API or the Provided Data in any other manner than as is legal, proper and in accordance with these Terms and Conditions.
If you are interested in doing anything different than the foregoing, you must first obtain Samtrafiken’ s written consent. If you fail to do so Samtrafiken reserves the right to terminate the API in accordance with section 10 below and, if deemed appropriate by Samtrafiken, to take legal action.
Provision of the API
The API and the Provided Data are provided on an “ as is” and “ as available” basis, with no warranties whatsoever regarding its security, reliability, timeliness, availability or performance. Thus, the Technical Documentation does not contain, and shall not be construed as, any binding commitment that i) the API will at all times meet the service levels set out therein; ii) the API will be uninterrupted, timely, secure or error-free or that iii) any errors in the Provided Data will be corrected, and Samtrafiken makes no such warranty or undertaking.
Samtrafiken may, at its sole discretion, change or release subsequent versions of the API: s, the Provided Data, the Technical Documentation or these Terms and Conditions, and require you to use and comply with the most current version. If a subsequent version is unacceptable to you, you may cancel the API at any time by deleting the API from your application, web service or similar development. If you continue to use the API in your application, web service or similar development you will be deemed to have accepted any updates or modifications. You can always review the most updated version of these Terms and Conditions and the most updated version of the Technical Documentation at www.trafiklab.se, or any successor URL that Samtrafiken may designate from time to time.
You acknowledge and agree that Samtrafiken and its partners own all legal right, title and interest, including without limitation all intellectual property rights, to the API and the Provided Data, and that you shall not acquire any right, title or interest in the API or the Provided data except as set forth in these Terms and Conditions.
For purposes of these Terms and Conditions, Samtrafiken hereby grants to you a non-transferable, non sub-licenseable, non-exclusive license during the term of these Terms and Conditions to display Samtrafikens trademarks, logotypes and domain names, in order to advertise that you are using the API. You hereby grant Samtrafiken a non-transferable, non sub-licenseable, non-exclusive license during the term of these Terms and Conditions to use your trademarks, logotypes and domain names to advertise that you are using the API. Except as set forth in this section 6, nothing in these Terms and Conditions shall grant or be deemed to grant one party any right, title or interest in the other party’ s name, trademarks, logos, domain names and other distinctive brand features.
Limitation of liability
You understand and agree that you use the API at your own discretion and risk, and agree that Samtrafiken and its partners shall not be liable to you for any direct, indirect or any other damages - including but not limited to damages for loss of data, loss of profits, loss of use or loss of goodwill - resulting from the use or the inability to use the API.
You agree to indemnify and hold harmless Samtrafiken and its agents, employees and partners against any third party claim arising from or otherwise related to your use of the API in violation of these Terms and Conditions, or any other actions connected with your use of the API or Provided Data, including any liability or expense arising from claims, losses, damages, suits, judgments, litigation costs or attorney’ s fees of every nature.
Processing of personal data
You understand and agree that any personal data provided by you to Samtrafiken may be processed by Samtrafiken for the purpose of administrating, supervising and rendering your use of the API more effective. In such processing, Samtrafiken is the controller of the personal data in accordance with Personuppgiftslag (1998:204).
You are entitled to information about Samtrafikens processing of your personal data, and to require that any erroneously processed personal data is corrected, blocked or deleted, by contacting Samtrafiken at firstname.lastname@example.org.
Term and termination
The term of these Terms and Conditions shall commence on the date upon which you agree to the Terms and Conditions, and shall continue in force thereafter unless terminated or changed as provided herein. Either party may terminate these Terms and Conditions at any time, and Samtrafiken reserves the right to terminate the provision of the API to you with immediate effect in case you use the API in breach of any of these Terms and Conditions. In addition, Samtrafiken reserves the right to change, suspend or discontinue all or any aspect of the API or the Provided Data at any time, for any reason, in which case Samtrafiken will strive to announce such change, suspension or discontinuation within a reasonable time before its implementation.
Upon the termination of these Terms and Conditions for any reason, all license rights granted herein shall terminate, and you must immediately cease to use and delete the API, the Provided Data and trademarks of Samtrafiken.
These Terms and Conditions constitute the entire agreement between you and Samtrafiken and govern your use of the API and the Provided Data, superseding any prior agreements between you and Samtrafiken.
These Terms and Conditions may be assigned by Samtrafiken and will inure to the benefit of Samtrafiken, its assignees and successors.
The failure of any party to enforce any right or provision of these Terms and Conditions shall not constitute a waiver of such right or provision. If any provision of these Terms and Conditions is found by a court of competent jurisdiction to be invalid, the parties nevertheless agree that the court should endeavor to give effect to the parties’ intentions as reflected in the provision, and the other provisions of the Terms and Conditions remain in full force and effect.
These Terms and Conditions are governed by the laws of Sweden, without regard to its conflict of laws provisions. Any dispute arising from these Terms and Conditions shall be settled in the courts of Sweden, with Stockholm district court as first instance.