Get Started

The Photrain API provides programmatic access to upload photos to our website www.photrain.net. This API uses OAuth 2.0 protocol for authorization. Before using our endpoints, you need to request an authorization token using your e-mail and password previously registered at www.photrain.net.

Please contact us using this form if you need help or if you have any questions or suggestions regarding this API.

Authorization

To get the authorization token you need to make a POST call to the following url:
https://api.photrain.net/token
Content-Type: application/x-www-form-urlencoded


Request Parameters

Field Type Description
username String Your Photrain.net account e-mail.
password String Your Photrain.net account password.
grant_type String The only grant_type supported is "password".

Response Parameters

Field Type Description
access_token String Your token to be used to access our endpoints.
token_type String The token type is always bearer.
expires_in Integer Token expiration time = 1 hour.

Upload

To upload a photo to Photrain.net you need to make a POST call to the following url:
https://api.photrain.net/photos/upload
Content-Type: multipart/form-data


Request Parameters

Field Type Description
image File The image file to be uploaded. Note that the image dimensions will follow your Photrain.net account restrictions.
operator String The operator portrayed in your photo (CP, Takargo, Renfe, SNCF...)
class String The class of the vehicle of your photo (1400, 253, 335...)
vehicleid String The vehicle ID of the vehicle portrayed in your photo (1413, 253.001, 335.001...)
description String (optional) Description of your photo.
tags String (optional) Enter a few words, separated by spaces, to identify your photo on the site.
location String The location of the photo (nearby city, village, etc.)
country String The two letter country code. Please use this list to find your two letter ISO Alpha-2 country code.
exif String (optional - default: 1) To show (or not) your photo EXIF info:
0: no
1: yes
date String (optional) The photo date. If no date is informed, it will use the current date or, if available, the date extracted from the EXIF.
latitude String (optional) The latitude location of your photo. This info can also be extracted from the EXIF, if available.
longitude String (optional) The longitude location of your photo. This info can also be extracted from the EXIF, if available.
imagedata String/Base64 (optional) If you wish, instead of uploading the image file, you can send it through a base 64 string, using this parameter.

Response Parameters

Field Type Description
photo Integer If the upload was successfull, it will display the photo id. If not, it will display the current errors.