NAV Navbar
Logo
shell ruby

Introduction

Welcome to the ULU API! You can use our API to access ULU API endpoints, which can get information on drivers, vehicles and trips from our database.

We have language bindings in Shell, Ruby, and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

If the request is made from HTTP you won’t get any response back from the API.

Authentication

To get security token, use this code:

    curl "https://api.ulu.io/api/v1/sessions"
        -H "Content-Type: application/json"
        -d '{"user":{"email":EMAIL,"password":PASSWORD}}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

uri = URI("https://api.ulu.io/api/v1/sessions")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json'
})
request.body = {user: {email: <EMAIL>, password: <PASSWORD>}}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "access_token": {
        "access_token": "98cb262acd66651ad100bf9c6b04bad8"
    },
    "user": {
        "id": 548,
        "firstname": "Žiga",
        "lastname": "Magajna",
        "address": "Tehnološki park",
        "housenumber": "20",
        "city": "Ljubljana",
        "phone": "06-00000000",
        "email": "g7424053@trbvm.com",
        "created_at": "2014-08-30T08:10:45.793Z",
        "updated_at": "2015-10-02T08:39:55.382Z",
        "vat_number": "SI00000000",
        "name": "Žiga Magajna",
        "email_verified": true,
        "picture": "/images/thumb/missing.png",
        "timezone": "Europe/Amsterdam",
        "sex": "m",
        "birthday": "23.05.1990",
        "terms_accepted_at": "2015-09-30T13:12:02.236Z"
    }
}

ULU uses a security token to allow access to the API. The token must be present in all API requests (except change_password, create user & login) in a header that looks like the following:

Authorization: "Token token = XXX"

Companies

Name Value Description
id INT This is the primary key of the table xy, it represents uniqe key in table.
name CHARACTER VARYING(255) Name of company.
email CHARACTER VARYING(255) Company email.
created_at TIMESTAMP WITHOUT TIME ZONE Time whan the trip was created.
updated_at TIMESTAMP WITHOUT TIME ZONE Time when the trip was updated.
timezone CHARACTER VARYING(255) DEFAULT ‘Europe/Amsterdam’ Timezone where the vehicle is in
address CHARACTER VARYING(255) Company address.
housenumber CHARACTER VARYING(10) Company housenumber.
city CHARACTER VARYING(255) Company city.
region CHARACTER VARYING(255) Company region.
country CHARACTER VARYING(3) DEFAULT 'NL’ Company country ISO2 standard.
zip_code CHARACTER VARYING(255) Company zip code.
vat_number CHARACTER VARYING(255) Company vat number.
registration_number CHARACTER VARYING(255) Company registration number.
phone CHARACTER VARYING(255) Company phone.
contact_name CHARACTER VARYING(255) Company contact name.
contact_phone CHARACTER VARYING(255) Company contact phone.
contact_email CHARACTER VARYING(255) Company email.
report_type_id INTEGER Report type id

GET My company

Return current authorized company.

curl "https://api.ulu.io/api/v1/companies/me"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
uri = URI("https://api.ulu.io/api/v1/companies/me")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "company": {
        "id": 548,
        "name": "test company",
        "email": "test@company.com",
        "created_at": "2015-07-21T11:54:20.852+02:00",
        "updated_at": "2015-07-21T11:55:08.169+02:00",
        "timezone": "Europe/Nederland",
        "address": "test address",
        "housenumber": "1a",
        "city": "Sky city",
        "region": "Left region",
        "country": "NL",
        "zip_code": "10280",
        "vat_number": "11111111",
        "registration_number": "34234321",
        "phone": "12332123",
        "contact_name": "Company contact",
        "contact_phone": "3213444",
        "contact_email": "company_contact@company.com",
        "report_type_id": 1
    }
}

GET Company

Return current company. It returns the company only if the creator of the company is the current authorized company. If not, return error.

curl "https://api.ulu.io/api/v1/companies/COMPANY_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
company_id = <COMPANY_ID>

uri = URI("https://api.ulu.io/api/v1/companies/#{company_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "company":
    {
        "id": 548,
        "name": "test company",
        "email": "test@company.com",
        "created_at": "2015-07-21T11:54:20.852+02:00",
        "updated_at": "2015-07-21T11:55:08.169+02:00",
        "timezone": "Europe/Nederland",
        "address": "test address",
        "housenumber": "1a",
        "city": "Sky city",
        "region": "Left region",
        "country": "NL",
        "zip_code": "10280",
        "vat_number": "11111111",
        "registration_number": "34234321",
        "phone": "12332123",
        "contact_name": "Company contact",
        "contact_phone": "3213444",
        "contact_email": "company_contact@company.com",
        "report_type_id": 1
    }
}

GET Companies

Return list of companies created by the current authorized company.

curl "https://api.ulu.io/api/v1/companies/"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/companies/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "companies": [
        {
            "company":"data..."
        }

    ]
}

POST Create company

Create company and admin user for this company. The function also returns the authentication token for the admin user.

curl "https://api.ulu.io/api/v1/companies"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X POST
        -d '{"comapny":{
                "name":"New Comapny",
                "email":"some@mycompany.com",'
                ...other parameters
                '},"user":{
                  "firstname":"Admin",
                  "lastname":"User",
                  "email":"admin@mycompany.com",
                  "password":"afinelongpassoword"
                }}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/companies/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {comapny:{name:"New Comapny",email:"some@mycompany.com"},user: {email:"admin@mycompany.com",password:"afinelongpassoword"}}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "company": [
        {
            "company":"data..."
        }

    ],
    "user": [
            {
                "user":"data..."
            }
        ],
    "authentication_token": {"authentication_token": "TOKEN"}
}

PUT Update company

Update data of company.

curl "https://api.ulu.io/api/v1/companies/COMPANY_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X PUT
        -d '{"company":{"name":"My New Company name"}}'"[name]=My company new name"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
comapny_id = <COMAPNY_ID>

uri = URI("https://api.ulu.io/api/v1/companies/#{comapny_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {comapny:{name:"My New Company name"}}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "company": [
        {
            "company":"data..."
        }

    ]
}

DELETE company

Delete company. But the company must not have users, vehicles, or other things connected to it.

curl "https://api.ulu.io/api/v1/companies/COMPANY_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X DELETE
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
comapny_id = <COMAPNY_ID>

uri = URI("https://api.ulu.io/api/v1/companies/#{comapny_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "company": [
        {
            "company":"data..."
        }

    ]
}

Users

Name Value Description
id INTEGER PRIMARY KEY This is the primary key of the table Users, it represents uniqe key in table.
firstname CHARACTER VARYING(255) Users first name.
lastname CHARACTER VARYING(255) Users last name.
name CHARACTER VARYING(255) Full name.
sex CHARACTER VARYING(2) ’m’ = MALE, ‘f’ = FEMALE.
birthday Date example format 1-1-1980
address CHARACTER VARYING(255) Address.
housenumber CHARACTER VARYING(255) House 'number’
city CHARACTER VARYING(255) City.
email CHARACTER VARYING(255) Email.
picture CHARACTER VARYING(255) If user has added picture.
created_at TIMESTAMP WITHOUT TIME ZONE When the user was created.
updated_at TIMESTAMP WITHOUT TIME ZONE When the user was updated.
phone CHARACTER VARYING(255) Phone number.
vat_number CHARACTER VARYING(50) Vat number of user.
email_verified BOOL If this value is false, the user wont be able to login in the ulu system
zip_code CHARACTER VARYING(255) Zip code.
post CHARACTER VARYING(255) Similar as city, some smaller places does not count as cities.
country CHARACTER VARYING(255) Country code. ISO2 standard
timezone CHARACTER VARYING(255) Timezone. Default “Europe/Amsterdam”

GET Create user

The newly created user will receive a confirmation email * country must be in iso2 standard

POST https://api.ulu.io/api/v1/users

    curl "https://api.ulu.io/api/v1/users"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -d '{"user":{
                "email":EMAIL,
                "password":PASSWORD,
                "sex":SEX,
                "firstname":FIRSTNAME,
                "lastname":LASTNAME,'
                ...other parameters
        '}}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/users")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {user: {
                  email:<EMAIL>,
                  password:<PASSWORD>,
                  firstname:<FIRSTNAME>,
                  lastname:<LASTNAME>,
                  ...other parameters
               }}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "user": {
        "id": 548,
        "birthday": "23-05-1990",
        "sex": "m",
        "email": "g7424053@trbvm.com",
        "firstname": "Žiga",
        "lastname": "Magajna",
        "name": "Žiga Magajna",
        "picture": "/images/thumb/missing.png",
        "address": "High tech campus",
        "housenumber": 1,
        "city": "Eindhoven",
        "phone": "123-123-432",
        "vat_number": "123321234",
        "zip_code": "6000",
        "post": "Eindhoven",
        "country": "NL",
        "timezone": "Europe/Amsterdam"
    }
}

URL Parameters

Parameter Description
EMAIL user email
PASSWORD user password (length 6 or more)
NAME user name.
BIRTHDAY birthday as string
SEX user gender, (’m’ or 'f’)
FIRSTNAME firstname of user
LASTNAME lastname of user
ADDRESS user address
HOUSENUMBER house number of user
CITY name of city
PHONE user phone number
VAT_NUMBER user vat number
ZIP_CODE User city zip code
POST Similar as city, some smaller places does not count as cities.
COUNTRY ISO2 standard country code
TIMEZONE Timezone in format “Europe/Amsterdam”

GET Reset

curl "https://api.ulu.io/api/v1/reset_password"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -d '{"user":{
              "email":EMAIL
        }}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/reset_password")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {user:{email:<EMAIL>}}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "user": {
        "id": 548,
        "birthday": "23.05.1990",
        "sex": "m",
        "email": "g7424053@trbvm.com",
        "firstname": "Žiga",
        "lastname": "Magajna",
        "name": "Žiga Magajna",
        "picture": "/images/thumb/missing.png"
    }
}

URL Parameters

Parameter Description
EMAIL users email

An password reset email will be sent to the indicated email

POST Change User Password

The user must be a part of the company, or the call will return a permission error.

curl "https://api.ulu.io/api/v1/update_user_password"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -d '{"user":{
                "old_password":OLD_PASSWORD,
                "password":NEW_PASSWORD,
                "password_confirmation":NEW_PASSWORD
          },"id":USER_ID}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/update_user_password")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {user:{
                  old_password:<OLD_PASSWORD>,
                  password:<NEW_PASSWORD>,
                  password_confirmation:<NEW_PASSWORD>},
                id:<USER_ID>}.to_json
response = http.request request
puts response.body

ERROR: if the passwords does not match, old password not right

{
    "success": false,
    "errors": {
        "old_password": [
            "Password is not correct."
        ]
    }
}

on SUCCESS

{
    "success": true,
    "errors": {},
    "user": {
        "id": 548,
        "birthday": "23.05.1990",
        "sex": "m",
        "email": "g7424053@trbvm.com",
        "firstname": "Žiga",
        "lastname": "Magajna",
        "name": "Žiga Magajna",
        "picture": "/images/thumb/missing.png"
    }
}

Company Users

Name Value Description
id INTEGER This is the primary key of the table CompanyUsers, it represents uniqe key in table.
role TEXT The role of the company user inside the company. Can be driver, fleet_admin and admin (admin can not be created via api, needs to be requested)
deleted BOOLEAN If the company user is deleted. If its deleted it will not appear in the index list.
current_vehicle TEXT List of vehicle license plates connected to the vehicle
current_company_groups STRING ARRAY String array of company groups, example: “[”{\“name\”:\“test\”,\“color\”:\“#d10fd1\”}“]”
custom_company_role_id INTEGER Id of the custom company role that the user is connected with.
current_company_user_schedule INTEGER Id of the current company user schedule the user is connected with.
username TEXT Customer username give to user if needed.
has_app_access BOOLEAN If the user has access to the web application or not.
available INTEGER If false, the user will not appear on the web application.
user USER User connected with the company user.

GET Company users

Get all company users for the currently logged in user/company

curl "https://api.ulu.io/api/v1/company_users[?page=PAGE_NO&limit=LIMIT_NO]"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"

on SUCCESS

{
    "success": true,
    "company_users": [
      {
        "id": 1541,
        "role": "driver",
        "deleted": false,
        "current_vehicle": "JKP12",
        "current_company_groups": "",
        "custom_company_role_id": null,
        "current_company_user_schedule": null,
        "username": null,
        "has_app_access": true,
        "available": true,
        "user": "USER"
      }
  ]
}

GET Company user

Get single company user

curl "https://api.ulu.io/api/v1/company_users/COMPANY_USER_ID[?page=PAGE_NO&limit=LIMIT_NO]"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"

on SUCCESS

{
    "success": true,
    "company_user":
      {
        "id": 1541,
        "role": "driver",
        "deleted": false,
        "current_vehicle": "JKP12",
        "current_company_groups": "",
        "custom_company_role_id": null,
        "current_company_user_schedule": null,
        "username": null,
        "has_app_access": true,
        "available": true,
        "user": "USER"
      }
}

POST Create company user

(aka link user to a company) If user does not exists, this also creates a new user. For parameters check the documentation on the user.

curl "https://api.ulu.io/api/v1/company_users"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company":{"id":COMPANY_ID},"user":{"id":USER_ID}}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/company_users")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {user:{id:<USER_ID>},company:{id:<COMPANY_ID}}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "company_user": {
        "id": 459,
        "role": null,
        "created_at": "2015-07-22T17:02:34.765+02:00",
        "updated_at": "2015-07-22T17:02:34.765+02:00",
        "deleted": false,
        "user": [
            {
                "user":"data..."
            }
        ]
    }
}

URL Parameters

Parameter Description
User user object, same as on the user create method
company_id Company with company id. If setting user for current company, this parameter can be left out

DELETE Company user

(aka unlink user from a company). The user is not deleted, just the link between the company and the user is removed.

curl "https://api.ulu.io/api/v1/company_users/COMPANY_USER_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X DELETE
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/company_users/COMPANY_USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})

response = http.request request
puts response.body

on SUCCESS

{
    "success": true
}

URL Parameters

Parameter Description
COMPANY_USER_ID The ID of the relation we want to delete

Company Groups

Name Value Description
id INTEGER This is the primary key of the table CompanyUsers, it represents uniqe key in table.
name TEXT The name of the group
color TEXT (hex format) Color of the company group, needs to be in hex format. Example: #10a0d0

POST Create company group

Create a new company group with a name and a color

curl "https://api.ulu.io/api/v1/company_groups"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group":{"name": "Test Group", "color": "#61b7d4"}}'

on SUCCESS

{
  "success": true,
  "company_group": {
    "id": 641,
    "company_id": 33,
    "name": "Test Group",
    "color": "#61b7d4"
  }
}

URL Parameters

Parameter Description
name group name
color color of the group hex format

PUT Update company group

Update company group

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group":{"name": "Test Group2"}}'
        -X PUT

on SUCCESS

{
  "success": true,
  "company_group": {
    "id": 641,
    "company_id": 33,
    "name": "Test Group2",
    "color": "#61b7d4"
  }
}

URL Parameters

Parameter Description
company_group_id id of the group
name group name
color color of the group hex format

GET Company groups

Get all company groups for the currently logged in user/company

curl "https://api.ulu.io/api/v1/company_groups?page=PAGE_NO&limit=LIMIT_NO"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X GET

on SUCCESS

{
  "success": true,
  "company_groups": [
    {
      "id": 641,
      "company_id": 33,
      "name": "Other test group",
      "color": "#10a0d0"
    },
    {
      "id": 180,
      "company_id": 33,
      "name": "test",
      "color": "#d10fd1"
    }
  ]
}

URL Parameters

Parameter Description
page current page number; optional
limit maximum number records returned per page; optional

GET Company group

Get company group based on id

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X GET

on SUCCESS

{
  "success": true,
  "company_group": {
    "id": 641,
    "company_id": 33,
    "name": "Other test group",
    "color": "#10a0d0"
  }
}

URL Parameters

Parameter Description
company_group_id id of the group

DELETE Company group

Delete company group based on ID

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X DELETE

on SUCCESS

{
  "success": true
}

URL Parameters

Parameter Description
company_group_id id of the group

Company User Groups

Name Value Description
id INTEGER This is the primary key of the table CompanyUserGroup, it represents unique key in table.
company_group_id INTEGER Id of the company group to connect the users with
company_user_id INTEGER Id of the company user to be connected
is_admin BOOLEAN If the user is admin or not of the group. BEWARE: When a user is made group admin he will be able to see only vehicles and users inside the given group.

POST Create company user group

Create a new company user group for the given vehicle and group

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/company_user_groups"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1, "company_user_group":{"company_user_id": 33, "is_admin": false}}'

on SUCCESS

{
  "success": true,
  "company_user_group": {
    "id": 641,
    "company_user_id": 33,
    "company_group_id": 1,
    "is_admin": false
  }
}

URL Parameters

Parameter Description
company_group_id Id of the company group
company_user_id Id of the company user
is_admin If user is admin or not

PUT Update company user group

Update company user group

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/company_user_groups/<COMPANY_USER_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1, "id": 33, "company_user_group":{"is_admin": true}}'
        -X PUT

on SUCCESS

{
  "success": true,
  "company_user_group": {
    "id": 641,
    "company_user_id": 33,
    "company_group_id": 1,
    "is_admin": true
  }
}

URL Parameters

Parameter Description
company_group_id Id of the company group
id Id of the company user group
is_admin If user is admin or not

GET Company user groups

Get all company user groups for the currently logged in user/company

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/company_user_groups[?page=PAGE_NO&limit=LIMIT_NO]"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1}'
        -X GET

on SUCCESS

{
  "success": true,
  "company_user_groups": [
    "company_user_group": {
      "id": 641,
      "company_user_id": 33,
      "company_group_id": 1,
      "is_admin": true
    },
    "company_user_group": {
      "id": 642,
      "company_user_id": 34,
      "company_group_id": 1,
      "is_admin": true
    }
  ]
}

URL Parameters

Parameter Description
company_group_id id of the group

GET Company user group

Get company user group based on id

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/company_user_groups/<COMPANY_USER_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1, "id": 33 }'
        -X GET

on SUCCESS

{
  "success": true,
  "company_user_group": {
    "id": 641,
    "company_user_id": 33,
    "company_group_id": 1,
    "is_admin": true
  }
}

URL Parameters

Parameter Description
company_group_id id of the group
id id of the company user group

DELETE Company user group

Delete company user group based on ID

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/company_user_groups/<COMPANY_USER_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1, "id": 33 }'
        -X DELETE

on SUCCESS

{
  "success": true
}

URL Parameters

Parameter Description
company_group_id id of the group
id id of the company user group

Vehicle company groups

Name Value Description
id INTEGER This is the primary key of the table CompanyUserGroup, it represents unique key in table.
company_group_id INTEGER Id of the company group to connect the users with
vehicle_id INTEGER Id of the vehicle to be connected

POST Create vehicle company group

Create a new vehicle company group for the given group and vehicle

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/vehicle_company_groups"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1, "vehicle_company_group":{"vehicle_id": 33}}'

on SUCCESS

{
  "success": true,
  "vehicle_company_group": {
    "id": 641,
    "vehicle_id": 33,
    "company_group_id": 1
  }
}

URL Parameters

Parameter Description
company_group_id Id of the company group
vehicle_id Id of the vehicle
is_admin If user is admin or not

GET Vehicle company groups

Get all vehicle company groups for the currently logged in user/company

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/vehicle_company_groups[?page=PAGE_NO&limit=LIMIT_NO]"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1}'
        -X GET

on SUCCESS

{
  "success": true,
  "vehicle_company_groups": [
    "vehicle_company_group": {
      "id": 641,
      "vehicle_id": 33,
      "company_group_id": 1
    },
    "vehicle_company_group": {
      "id": 642,
      "vehicle_id": 34,
      "company_group_id": 1,
    }
  ]
}

URL Parameters

Parameter Description
company_group_id id of the group

GET Vehicle company group

Get vehicle company group based on id

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/vehicle_company_groups/<VEHICLE_COMPANY_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1, "id": 33 }'
        -X GET

on SUCCESS

{
  "success": true,
  "vehicle_company_group": {
    "id": 641,
    "vehicle_id": 33,
    "company_group_id": 1
  }
}

URL Parameters

Parameter Description
company_group_id id of the group
id id of the vehicle company group

DELETE Vehicle company group

Delete vehicle company group based on ID

curl "https://api.ulu.io/api/v1/company_groups/<COMPANY_GROUP_ID>/vehicle_company_groups/<VEHICLE_COMPANY_GROUP_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"company_group_id": 1, "id": 33 }'
        -X DELETE

on SUCCESS

{
  "success": true
}

URL Parameters

Parameter Description
company_group_id id of the group
id id of the vehicle company group

Ibuttons

Name Value Description
id INTEGER This is the primary key of the table Ibuttons, it represents uniqe key in table.
identification_number TEXT The ibutton number (except the first two digits as they are associated with the type)
identification_type TEXT Can be 00 for RFIDS or 01 for ibuttons

POST Create ibutton

Create a new ibutton for the specific type

curl "https://api.ulu.io/api/v1/settings/ibuttons"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"ibutton":{"identification_number": "0100001B11958174", "identification_type": "01"}}'

on SUCCESS

{
  "success": true,
  "ibutton": {
    "id": 641,
    "identification_number": "0100001B11958174",
    "identification_type": "01"
  }
}

URL Parameters

Parameter Description
identification_number number of the ibutton
identification_type type of the ibutton

PUT Update ibutton

Update ibutton

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"ibutton":{"identification_number": "0100001B11958175"}}'
        -X PUT

on SUCCESS

{
  "success": true,
  "ibutton": {
    "id": 641,
    "identification_number": "0100001B11958175",
    "identification_type": "01"
  }
}

URL Parameters

Parameter Description
identification_number number of the ibutton
identification_type type of the ibutton

GET Ibuttons

Get all company ibuttons for the currently logged in user/company

curl "https://api.ulu.io/api/v1/settings/ibuttons?page=PAGE_NO&limit=LIMIT_NO"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X GET

on SUCCESS

{
  "success": true,
  "ibuttons": [
    {
      "id": 641,
      "identification_number": "0100001B11958175",
      "identification_type": "01"
    },
    {
      "id": 642,
      "identification_number": "0100001B11958176",
      "identification_type": "01"
    }
  ],
  "total_pages": 1,
  "current_page": 1,
  "has_more": false
}

URL Parameters

Parameter Description
page current page number; optional
limit maximum number records returned per page; optional
total_pages total number of pages that the pagination offers
current_page the current page the api calls are currently on
has_more if the request has more pages

GET ibutton

Get ibutton based on id

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X GET

on SUCCESS

{
  "success": true,
  "ibutton": {
    "id": 642,
    "identification_number": "0100001B11958176",
    "identification_type": "01"
  }
}

URL Parameters

Parameter Description
ibutton_id id of the ibutton

DELETE Ibutton

Delete ibutton based on ID

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X DELETE

on SUCCESS

{
  "success": true
}

URL Parameters

Parameter Description
ibutton_id id of the ibutton

User ibuttons

Name Value Description
id INTEGER This is the primary key of the table UserIbutton, it represents unique key in table.
ibutton_id INTEGER Id of the ibutton to connect the users with
user_id INTEGER Id of the user to be connected
start_at DATETIME Datetime when the connection starts being valid
trip_type_id INTEGER 1 for private, 2 for business, 3 for commute and 6 for driver switch
stop_at DATETIME Datetime when the connection stops being valid, until is null is treated as valid

POST Create user ibutton

Create a new user ibutton for the given user and group

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>/user_ibuttons"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"ibutton_id": 1, "user_ibutton":{"user_id": 33, "trip_type_id": 1, "start_at": "2018-10-18 15:41:37"}}'

on SUCCESS

{
  "success": true,
  "user_ibutton": {
    "id": 641,
    "user_id": 33,
    "trip_type_id": 1,
    "start_at": "2018-10-18 15:41:37",
    "stop_at": ""
  }
}

URL Parameters

Parameter Description
ibutton_id Id of the ibutton
user_id Id of the user
start_at Datetime when the connection starts being valid
trip_type_id 1 for private, 2 for business, 3 for commute and 6 for driver switch
stop_at Datetime when the connection stops being valid, until is null is treated as valid

PUT Update user ibutton

Update user ibutton

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>/user_ibuttons/<USER_IBUTTON_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"ibutton_id": 1, "id": 641, "user_ibutton":{"trip_type_id": 2}}'
        -X PUT

on SUCCESS

{
  "success": true,
  "user_ibutton": {
    "id": 641,
    "user_id": 33,
    "trip_type_id": 1,
    "start_at": "2018-10-18 15:41:37",
    "stop_at": ""
  }
}

URL Parameters

Parameter Description
id (USER_IBUTTON_ID) ID of the user ibutton
ibutton_id Id of the ibutton
user_id Id of the user
start_at Datetime when the connection starts being valid
trip_type_id 1 for private, 2 for business, 3 for commute and 6 for driver switch
stop_at Datetime when the connection stops being valid, until is null is treated as valid

GET User ibuttons

Get all user ibuttons for the currently logged in user/company and give ibutton

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>/user_ibuttons?page=PAGE_NO&limit=LIMIT_NO"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"ibutton_id": 1}'
        -X GET

on SUCCESS

{
  "success": true,
  "user_ibuttons": [
    "user_ibutton": {
      "id": 641,
      "user_id": 33,
      "trip_type_id": 1,
      "start_at": "2018-10-18 15:41:37",
      "stop_at": ""
    },
    "user_ibutton": {
      "id": 642,
      "user_id": 34,
      "trip_type_id": 1,
      "start_at": "2018-10-18 15:41:37",
      "stop_at": ""
    }
  ]
}

URL Parameters

Parameter Description
ibutton_id id of the ibutton
page current page number; optional
limit maximum number records returned per page; optional

GET User ibutton

Get user ibutton based on id

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>/user_ibuttons/<USER_IBUTTON_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"ibutton_id": 1, "id": 33 }'
        -X GET

on SUCCESS

{
  "success": true,
  "user_ibutton": {
    "id": 641,
    "user_id": 33,
    "trip_type_id": 1,
    "start_at": "2018-10-18 15:41:37",
    "stop_at": ""
  }
}

URL Parameters

Parameter Description
ibutton_id id of the ibutton
id id of the user ibutton

DELETE User ibutton

Delete user ibutton based on ID

curl "https://api.ulu.io/api/v1/settings/ibuttons/<IBUTTON_ID>/user_ibuttons/<USER_IBUTTON_ID>"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"ibutton_id": 1, "id": 33 }'
        -X DELETE

on SUCCESS

{
  "success": true
}

URL Parameters

Parameter Description
ibutton_id id of the ibutton
id id of the user ibutton

Devices

Name Value Description
device_id INTEGER This is the device id of the device
imei ICHARACTER VARYING(255) ULU device IMEI
created_at TIMESTAMP WITHOUT TIME ZONE When the created was created.
updated_at TIMESTAMP WITHOUT TIME ZONE When the updated was updated.

GET Devices

for company

curl "https://api.ulu.io/api/v1/devices[?updaired=True]"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/devices[?updaired=True]")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "devices": [
        {
            "imei": "013777009999999",
            "device_id": 1377700999999,
            "created_at": "2014-09-22T20:34:11.072+02:00",
            "updated_at": "2014-09-22T20:34:11.000+02:00"
        },
        {
            "imei": "013777009999988",
            "device_id": 1377700999998,
            "created_at": "2014-10-23T16:20:04.344+02:00",
            "updated_at": "2015-03-13T11:29:35.152+01:00"
        }
    ]
}

Parameters

Parameter Description
UNPAIRED Return unpaired dongles

Vehicles

Name Value Description
id INTEGER This is the primary key of the table Vehicles, it represents uniqe key in table.
vin TEXT This is the vehicle identification number that user writes.
modelyear INTEGER This we get from resolvment of the vin/licence_plate number or license plate - it is the yer when this model was build
make TEXT This we get from resolvment of the vin/licence_plate number or license plate - it is the make of the vehcile
model TEXT This we get from resolvment of the vin/licence_plate number or license plate - it is the model of the vehicle
manufacturedin TEXT This we get from resolvment of the vin/licence_plate number or license plate - where the car was manufactured.
enginetype TEXT This we get from resolvment of the vin/licence_plate number or license plate - Engine type of vehicle
transmission TEXT This we get from resolvment of the vin/licence_plate number or license plate - Transmition of the vehicle.
driveline TEXT This we get from resolvment of the vin/licence_plate number or license plate
steeringtype TEXT This we get from resolvment of the vin/licence_plate number or license plate
seating INTEGER This we get from resolvment of the vin/licence_plate number or license plate
created_at TIMESTAMP When the vehicle was created in our database.
updated_at TIMESTAMP When the vehicle was updated in our database.
vehicle_class TEXT This we get from resolvment of the vin/licence_plate number or license plate
vehicle_type TEXT This we get from resolvment of the vin/licence_plate number or license plate
enginetype2 TEXT This we get from resolvment of the vin/licence_plate number or license plate - Engine type of vehicle, if hybrid
trip_score NUMERIC(13,2) Avg score of the trips for this vehicle.
device_id BIGINT Device on this vehicle.
color TEXT This we get from resolvment of the vin/licence_plate number or licence plate.
license_plate TEXT License plate of the vehicle.
updated_odometer_at TIMESTAMP When the user updated the odometer(for the sum of the trip and right odometer).
privacy TEXT DEFAULT ‘business’ On witch privacy is vehiacle on. deprecated, will be removed on 14.8.2015
trip_type_id INTEGER DEFAULT 2 - business On witch privacy is vehicle on. Check the different by calling trip_types (more in the trips documentation)
name TEXT Name of the vehicle.
state TEXT DEFAULT 'unpaired’ Is the vehicle active.
country TEXT DEFAULT 'NL’ Country of the car(Timezone helper).
fuel_level FLOAT DEFAULT 0.0 Last fuel level of the car.
battery_level FLOAT DEFAULT 0.0 Last battery level of the car.
lon FLOAT DEFAULT 0.0 Longitude of the last location.
lat FLOAT DEFAULT 0.0 Latitude of the last location.
speed INTEGER Last speed of the car.
osm_place TEXT DEFAULT 'unknown’ Place of the last location.
osm_country TEXT DEFAULT 'unknown’ Country of the last location.
osm_road_name TEXT DEFAULT 'unknown’ Road name of the last location
timezone TEXT DEFAULT 'Europe/Amsterdam’ Timezone where the vehicle is in
obd_odometer INTEGER If we can read data from vehicle odometer(most of the time will be NULL).
company_id INTEGER If owner is user, than this value shows the id of the company, that has permissions to view the vehicle (if there is one). If owner is company, that this is the id of the owning company
user_id INTEGER If owner is company, than this value displays the currenct driver id of the vehicle (if there is one), if owner is user, that returns owner user id
odometer INTEGER Last manually inputed odometer + distance of trips
heartbeat TIMESTAMP Last heartbeat
datetime_service TIMESTAMP User updated datetime service
datetime_oil_change TIMESTAMP User updated datetime oil change
datetime_tire_rotation TIMESTAMP User updated datetime tire rotation
datetime_registration TIMESTAMP User updated datetime registration
engine_state BOOLEAN Vehicle driving of parked
vehicle_errors ARRAY Array of vehicle errors
trip_no INTEGER Count of all the trips of this vehicles.
owner_user_id INTEGER If this value is set, than owner_company_id is not set. Returns id of user owner of vehicle.
owner_company_id INTEGER If this value is set, than owner_user_id is not set. Returns id of company owner of vehicle.
rpm INTEGER Rotations per minute.
number_of_cylinders INTEGER This we get from resolvment of the vin/licence_plate number or license plate
cylinder_content INTEGER This we get from resolvment of the vin/licence_plate number or license plate
weight_empty_vehicle INTEGER This we get from resolvment of the vin/licence_plate number or license plate
number_of_doors INTEGER This we get from resolvment of the vin/licence_plate number or license plate
power INTEGER This we get from resolvment of the vin/licence_plate number or license plate - in metric horse power, converted from kw (one_metric_horse_power_in_kw = 0.73549875)
emission_code CHARACTER VARYING(50) This we get from resolvment of the vin/licence_plate number or license plate
fuel_consumption_urban NUMERIC(5,3) This we get from resolvment of the vin/licence_plate number or license plate
fuel_consumption_extraurban NUMERIC(5,3) This we get from resolvment of the vin/licence_plate number or license plate
fuel_consumption_combined NUMERIC(5,3) This we get from resolvment of the vin/licence_plate number or license plate
co2_emission_combined NUMERIC(10,2) This we get from resolvment of the vin/licence_plate number or license plate
topspeed INTEGER This we get from resolvment of the vin/licence_plate number or license plate
driver_id INTEGER id of the user that is assigned as driver of the vehicle
location STRING The current location of the vehicle
heartbeat TIMESTAMP Last time that vehicle send the event to server
virtual_odometer INTEGER BETA! Not yet tested firmware
heartbeat_at TIMESTAMP Last time that vehicle send the event to server
device_first_data_at TIMESTAMP When vehicle first send data
version INTEGER What version of firmware is on vehicle
next_prediction_service_on TIMESTAMP When the preditction of the service should be
next_service_odometer_trigger_on INTEGER Send event if odometer is on this milage
last_service_on TIMESTAMP Data of last service
last_service_odometer_trigger_on INTEGER Date when the service was last trigged by odometer
next_vehicle_inspection_date DATE Date of the next vehicle inspection(NL - Updated automaticlly after the date when the APK should be done)
company_groups ARRAY Array of company groups that the vehicle is in. Example of the company group object { id: 180, color: “#d10fd1”,name: “test” }

Change owner of vehicle

By updating the values owner_user_id or owner_company_id the owner of the vehicle can be changed. The update is done by calling the UPDATE method of the vehicle (or on the first CREATE). If the owner of the vehicle is a company, than the ownership can be changed to user, by setting the owner_user_id. WARNING: By doing this all the permissions of the vehicle are given to the user and the company will not be able to view the vehicle anymore. Also the user must be part of the company, or the update will return an error. Same for switching the ownership from user to company.

GET Vehicles

Get all vehicles for the currently logged in user

curl "https://api.ulu.io/api/v1/vehicles[?page=PAGE_NO&limit=LIMIT_NO]"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/vehicles[?page=PAGE_NO&limit=LIMIT_NO]")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success":true,
    "errors":{},
    "vehicles": [
        {
                "vehicle": "data..."
        }
    ]

}

GET Vehicle

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/#{vehicle_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "vehicle": {
        "id": 29,
        "vin": "YV1CZ714661264975",
        "modelyear": 2006,
        "make": "V50 Volvo",
        "model": "",
        "manufacturedin": "Volvo Car Corp",
        "enginetype": "L5",
        "transmission": "Automatic",
        "driveline": "AWD",
        "steeringtype": "",
        "seating": 5,
        "created_at": "2014-08-28T11:27:05.355+02:00",
        "updated_at": "2015-11-13T11:18:06.646+01:00",
        "vehicle_class": "Large SUV",
        "vehicle_type": "Large SUV",
        "trip_score": "0.88",
        "device_id": 1377700225704,
        "color": null,
        "license_plate": "LJUP443",
        "updated_odometer_at": "2015-09-03T12:11:26.521+02:00",
        "privacy": "business",
        "name": "Volvo V50",
        "state": "active",
        "country": "SI",
        "fuel_level": "0.65",
        "battery_level": "13.52",
        "lon": "14.46011",
        "lat": "46.049475",
        "speed": 0,
        "osm_place": "Ljubljana",
        "osm_country": "SI",
        "osm_road_name": "Tehnološki park",
        "timezone": "Europe/Ljubljana",
        "obd_odometer": 221599958,
        "trip_type_id": 2,
        "rpm": 0,
        "enginetype2": null,
        "number_of_cylinders": null,
        "cylinder_content": null,
        "weight_empty_vehicle": null,
        "number_of_doors": null,
        "power": null,
        "emission_code": null,
        "fuel_consumption_urban": "0.0",
        "fuel_consumption_extraurban": "0.0",
        "fuel_consumption_combined": "0.0",
        "co2_emission_combined": "0.0",
        "topspeed": null,
        "driver_id": 432,
        "heartbeat_at": "2015-11-13T10:17:42.005+01:00",
        "device_first_data_at": "2014-04-09T08:48:07.000+02:00",
        "version": null,
        "trip_no": 2033,
        "odometer": 224518205,
        "next_prediction_service_on": "2016-02-16",
        "next_service_on": "2016-02-16",
        "next_service_odometer_trigger_on": 230000000,
        "next_vehicle_inspection_date": null,
        "last_service_on": "2015-01-11",
        "last_service_odometer_trigger_on": 199256000,
        "virtual_odometer": null,
        "company_id": 102,
        "user_id": 432,
        "owner_user_id": 432,
        "owner_company_id": null,
        "location": "Tehnološki park, Ljubljana",
        "heartbeat": "2015-11-13T10:17:42.005+01:00",
        "datetime_service": null,
        "datetime_oil_change": null,
        "datetime_tire_rotation": null,
        "datetime_registration": null,
        "engine_state": false,
        "vehicle_errors": [
            {
                "id": 131651,
                "vehicle_id": 29,
                "device_id": 1377700225704,
                "code": "C0104",
                "status": "current",
                "created_at": "2015-11-10T15:38:47.364+01:00",
                "updated_at": "2015-11-10T18:22:08.591+01:00",
                "start_status": "current",
                "cleared_at": null,
                "last_occurrence_at": "2015-11-10T18:22:08.590+01:00",
                "count_for_period": 23,
                "vehicle_error_description": null
            }
        ]
    }
}

URL Parameters

Parameter Description
VEHICLE_ID The ID of the car to retrieve

GET Create vehicle

curl "https://api.ulu.io/api/v1/vehicles/"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"vehicle":{
                "odometer":ODOMETER,
                "imei":IMEI,
                "name":NAME,
                "company_id":COMPANY_ID,'
                ...other parameters
            '}}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {vehicle:{
                  odometer:<ODOMETER>,
                  imei:<IMEI>,
                  name:<NAME>,
                  company_id:<COMPANY_ID>,
                  ...other parameters
               }}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success":true,
    "errors":{},
    "vehicles": [
        {
                "vehicle": "data..."
        }
    ]

}

Vehicle Parameter

Parameter Description
ODOMETER current vehicle odometer in meters
IMEI ulu dongle imei
NAME (optional) vehicle name
COMPANY_ID company id

PUT Update vehicle

In this call you can update vehicle with new values.

Also with the update function a new device can be assigned to a already existing vehicle. Conditions - the device_id on the vehicle must be nil (so no other devices are connected to this vehicle) - the new device must not be connected to an active vehicle

to switch just add device_id in the parameters of the vehicle (vehicle[device_id]). The device_id is the imei of the device, without the first and last digit.

Parameter Description
VEHICLE_ID Id vehicle that you want to update
curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"vehicle":{
                "odometer":ODOMETER,
                "imei":IMEI,
                "name":NAME,
                "company_id":COMPANY_ID,'
                ...other parameters
            '}}'
        -X PUT
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/VEHICLE_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {vehicle:{
                  odometer:<ODOMETER>,
                  imei:<IMEI>,
                  name:<NAME>,
                  company_id:<COMPANY_ID>,
                  ...other parameters
               }}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success":true,
    "errors":{},
    "vehicles": [
        {
                "vehicle": "data..."
        }
    ]

}

on SUCCESS

{
    "success":true,
    "errors":{},
    "vehicles": [
        {
                "vehicle": "data..."
        }
    ]

}

POST Disconnect device from vehicle

The status of the vehicle will be changed to disconnect and the device_id attribute to nil. This device will now be able to be added to a new vehicle

Parameter Description
VEHICLE_ID Id vehicle that you want to disconnect
curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID/disconnect"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X POST
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/#{vehicle_id}/disconnect")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success":true,
    "errors":{},
    "vehicles": [
        {
                "vehicle": "data..."
        }
    ]

}

DELETE Vehicle

The status of the vehicle will be changed to deleted and the device_id attribute to nil. This device will now be able to be added to a new vehicle

Parameter Description
VEHICLE_ID Id vehicle that you want to delete
curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X DELETE
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/#{vehicle_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success":true,
    "errors":{},
    "vehicles": [
        {
                "vehicle": "data..."
        }
    ]

}

GET Scores

for vehicle for duration from date A to date B. Example of the time: 2017-02-23T00:00

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID/scores_for_period"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"from_date":DATE_FROM,"to_date":DATE_TO}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/#{vehicle_id}/scores_for_period")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {from_date:<DATE_FROM>,to_date:<TO_DATE>}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "scores": {
        "score": 0.6922330097087379,
        "scores": [
            {
                "name": "speed",
                "score": 0
            },
            {
                "name": "acceleration",
                "score": 0.3605825242718447
            },
            {
                "name": "idle",
                "score": 0.8174757281553398
            },
            {
                "name": "braking",
                "score": 0.34689320388349515
            }
        ],
        "previous_week_score": 0.637,
        "tip": "Looking good, keep up the good driving!"
    }
}

URL Parameters

Parameter Description
VEHICLE_ID The car for scores
DATE_FROM Start period for scores
DATE_TO End period for scores

Vehicle error

Name Value Description
id INTEGER PRIMARY KEY This is the primary key of the table Vehicle Errors, it represents uniqe key in table.
vehicle_id INTEGER This is the represents vehicle id on vehicle errors table.
user_id INTEGER NEED’s TO BE REMOVED!!!!!
device_id BIGINT Device on this vehicle error.
code CHARACTER VARYING(255) Code of the error.
description TEXT Description of the error.
status CHARACTER VARYING(255) State of the error(pending, current, permanent, cleared).
created_at TIMESTAMP WITHOUT TIME ZONE When the error was created.
updated_at TIMESTAMP WITHOUT TIME ZONE When the error was updated.
start_status TEXT What was the status of error on the vehicles(description in example)
cleared_at TIMESTAMP When the error was cleared(If is not cleared then the API will return null)
last_occurrence_at TIMESTAMP When this error last occured.
count_for_period INTEGER How manny times this error occured.

GET Vehicle errors

URL Parameters

Parameter Description
VEHICLE_ID The ID of the car to retrieve
curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID/vehicle_errors"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/#{vehicle_id}/vehicle_errors")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "vehicle_errors": [
        {
            "id": 131651,
            "vehicle_id": 29,
            "device_id": 1377700225704,
            "code": "C0104",
            "status": "current",
            "created_at": "2015-11-10T15:38:47.364+01:00",
            "updated_at": "2015-11-10T18:22:08.591+01:00",
            "start_status": "current",
            "cleared_at": null,
            "last_occurrence_at": "2015-11-10T18:22:08.590+01:00",
            "count_for_period": 23
        }
    ]
}

On the vehicle there are three statuse of errors:

Trips

Name Value Description
id INT This is the primary key of the table xy, it represents uniqe key in table.
device_id BIGINT This is the uniqe representation of the device.
vehcile_id INT This is the represents vehicles id on trips table.
privacy CHARACTER VARYING(255) The user set of privacy(business/private).
trip_type_id INT) The user set of privacy(business - 2 /private - 1/commute - 3). Will take the place of privacy
created_at TIMESTAMP WITHOUT TIME ZONE Time whan the trip was created.
updated_at TIMESTAMP WITHOUT TIME ZONE Time when the trip was updated.
duration INTEGER DEFAULT 0 It is the diffrence between start and stop ts.
max_speed SMALL INT DEFAULT 0 We get this in obdEot or obdHEot.
distance INTEGER DEFAULT 0 We get this in obdEot or obdHEot.
idle_duration INTEGER DEFAULT 0 We get this in obdEot or obdHEot.
avg_speed NUMERIC(5,2) DEFAULT 0.0 Calculated between distance and obd_duration.
start_road_name CHARACTER VARYING(255) The first road name on the points.
start_road_place CHARACTER VARYING(255) The first place on the points.
start_road_country CHARACTER VARYING(15) The first country on the points.
stop_road_name CHARACTER VARYING(255) The last road name on points.
stop_road_place CHARACTER VARYING(255) The last place on points.
stop_road_country CHARACTER VARYING(15) The last country on points.
score NUMERIC(3,2) DEFAULT 0.0 The score calculated between speeding score(50%), idle score(10%), acceleration score(20%) and braking score(20%) and it is between 0 and 1
utc_start_at TIMESTAMP WITHOUT TIME ZONE The start time of the car driving utc value
utc_stop_at TIMESTAMP WITHOUT TIME ZONE The stop time of the car driving utc value
start_at TIMESTAMP WITHOUT TIME ZONE The start time of the car driving utc value + offset depending on location
stop_at TIMESTAMP WITHOUT TIME ZONE The stop time of the car driving + offset depending on location
distance_electric INTEGER Distance that is droven on electric(Hybrid cars)
user_id INTEGER User that drove vehicle
company_id INTEGER Company that has permission to this trip
odometer_start INTEGER Start odometer of vehicle that drove this trip
odometer_stop INTEGER Stop odometer of vehicle that drove this trip
notes TEXT Notes on trip
device_owner_id INTEGER Owenr of the device
device_owner_type TEXT Type of owner company/user
vehicle_owner_id INTEGER Owner of vehicle
vehicle_owner_type TEXT Type of owner company/user
driver_id INTEGER Id of user driver
max_rpm INTEGER Max of RPM on trip
start_lon FLOAT Start longitude of resolved first point
start_lat FLOAT Start latitude of resolved first point
stop_lon FLOAT Longitude of resolved last point
stop_lat FLOAT Latitude of resolved last point
start_road_zip_code TEXT Start postal code on trip
stop_road_zip_code TEXT Stop postal code on trip
start_road_house_number TEXT Start housenumber on trip
stop_road_house_number TEXT Stop housenumber on trip
start_road_region TEXT Start region on trip
stop_road_region TEXT Stop region on trip
deleted_at TIMESTAMP When the trip was deleted
common_trip_scores SCORES All the data about the scores and vectors
points_vector VECTOR Array of points with speeding events
acceleration_event_points POINTS Array of points where the accelerations accured
braking_event_points POINTS Array of points where the braking accured

GET Trips

for vehicle and between two timestamps. Example of the time: 2017-02-23T00:00

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID/trips"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -d '{"from_start_at":DATE_FROM,"to_start_at":DATE_TO}'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
vehicle_id = <VEHICLE_ID>

uri = URI("https://api.ulu.io/api/v1/vehicles/#{vehicle_id}/trips")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
request.body = {from_start_at:<DATE_FROM>,to_start_at:<TO_DATE>}.to_json
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "trips": [
        {
            "trip": "data..."
        }
    ]
}

URL Parameters

Parameter Description
VEHICLE_ID The ID of the car to retrieve
FROM_START_AT from date(time)
TO_START_AT to date(time)

GET Trip

curl "https://api.ulu.io/api/v1/trips/TRIP_ID"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
trip_id = <TRIP_ID>

uri = URI("https://api.ulu.io/api/v1/trips/#{trip_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "errors": {},
    "trip": {
        "id": 242070,
        "device_id": 9000000000050,
        "vehicle_id": 1376,
        "privacy": "commute",
        "created_at": "2015-11-13T10:57:10.011+01:00",
        "updated_at": "2015-11-13T13:16:59.876+01:00",
        "duration": 275,
        "max_speed": 16,
        "distance": 589,
        "idle_duration": 0,
        "avg_speed": "7.71",
        "start_road_name": "Van der Palmkade",
        "start_road_place": "Amsterdam",
        "start_road_country": "NL",
        "stop_road_name": "Eerste Keucheniusstraat",
        "stop_road_place": "Amsterdam",
        "stop_road_country": "NL",
        "score": "0.89",
        "utc_start_at": "2015-11-13T10:56:43.000+01:00",
        "utc_stop_at": "2015-11-13T11:01:18.312+01:00",
        "start_at": "2015-11-13T11:56:43.000+01:00",
        "stop_at": "2015-11-13T12:01:18.312+01:00",
        "trip_type_id": 3,
        "distance_electric": 0,
        "user_id": 50,
        "company_id": 33,
        "odometer_start": 3881,
        "odometer_stop": 4470,
        "notes": null,
        "device_owner_id": 33,
        "device_owner_type": "Company",
        "vehicle_owner_id": 33,
        "vehicle_owner_type": "Company",
        "driver_id": 50,
        "max_rpm": 0,
        "start_lon": "4.87348",
        "start_lat": "52.38113",
        "stop_lon": "4.87227",
        "stop_lat": "52.38127",
        "start_road_zip_code": "1051",
        "stop_road_zip_code": "1051 HS",
        "start_road_house_number": null,
        "stop_road_house_number": "22-1",
        "start_road_region": "North Holland",
        "stop_road_region": "North Holland",
        "deleted_at": null,
        "common_trip_scores": [
            {
                "id": 2136252,
                "trip_id": 242070,
                "nice_id": "acceleration",
                "score": "1.0",
                "created_at": "2015-11-13T11:57:16.767+01:00",
                "updated_at": "2015-11-13T13:14:52.738+01:00",
                "key": "acceleration_amazing",
                "name": "Acceleration",
                "description": "WOW! Only the best drivers have an amazing acceleration score. Keep up the smooth ride. Go ULU star.",
                "stars": 5
            },
            {
                "id": 2136253,
                "trip_id": 242070,
                "nice_id": "braking",
                "score": "1.0",
                "created_at": "2015-11-13T11:57:16.767+01:00",
                "updated_at": "2015-11-13T13:14:52.753+01:00",
                "key": "braking_amazing",
                "name": "Braking",
                "description": "WOW! Only the best drivers have an amazing breaking score. Keep up the smooth ride. Go ULU star.",
                "stars": 5
            },
            {
                "id": 2136254,
                "trip_id": 242070,
                "nice_id": "idle",
                "score": "1.0",
                "created_at": "2015-11-13T11:57:16.767+01:00",
                "updated_at": "2015-11-13T11:57:16.767+01:00",
                "key": "idle_amazing",
                "name": "Idle",
                "description": "WOW! You can't do any better than this. Only the best keep their engines off when not moving.",
                "stars": 5
            },
            {
                "id": 2136251,
                "trip_id": 242070,
                "nice_id": "speeding",
                "score": "0.77",
                "created_at": "2015-11-13T11:57:16.767+01:00",
                "updated_at": "2015-11-13T13:16:01.808+01:00",
                "key": "speeding_good",
                "name": "Speeding",
                "description": "You are doing good in respecting the posted speed limits. Improving minor violations that you have will get you a perfect score and even further reduce the fuel consumption of your car.",
                "stars": 4
            }
        ],
        "points_vector": [
            {
                "color": "#1099E0",
                "points": [
                    [52.38113,4.87348],
                    [52.3809,4.87344]
                ],
                "type": "normal"
            },
            {
                "color": "#F8E71C",
                "points": [
                    [52.3809,4.87344],
                    [52.38028,4.8733],
                    [52.38028,4.8733],
                    [52.37974,4.8732],
                    [52.37958,4.87312],
                    [52.37943,4.87299]
                ],
                "type": "speeding"
            },
            {
                "color": "#1099E0",
                "points": [
                    [52.37943,4.87299],
                    [52.37909,4.87266],
                    [52.37909,4.87266],
                    [52.37919,4.87236],
                    [52.37919,4.87236],
                    [52.37933,4.87194],
                    [52.37938,4.87183],
                    [52.37938,4.87183],
                    [52.37944,4.87177],
                    [52.37957,4.87169],
                    [52.37957,4.87169],
                    [52.37962,4.87167],
                    [52.37962,4.87167],
                    [52.37969,4.87164],
                    [52.37969,4.87164],
                    [52.37997,4.87154],
                    [52.37997,4.87154],
                    [52.38021,4.87146],
                    [52.38021,4.87146],
                    [52.38046,4.87137],
                    [52.38046,4.87137],
                    [52.38069,4.87129],
                    [52.38069,4.87129],
                    [52.38079,4.87126],
                    [52.38079,4.87126],
                    [52.38096,4.8712],
                    [52.38096,4.8712],
                    [52.38103,4.87149],
                    [52.38119,4.87238]
                ],
                "type": "normal"
            }
        ],
        "acceleration_event_points": [],
        "braking_event_points": []
    }
}

URL Parameters

Parameter Description
TRIP_ID The ID of the car to retrieve

POST Create trip TRACKER APP ONLY!!!!

(e.q. create a new trip from data)

URL Parameters

Name Value Description
DEVICE_ID INTEGER DEVICE ID = 9000000000000 + USER_ID
IMEI STRING IMEI = “M”+DEVICE+ID+“M”
TIMESTAMP INTEGER ts_start * 1000
VALUES contains the “BATCH” dictionary which contains COORDINATE array values = {batch = [coordinate1, coordinate2,..]}

COORDINATE

Name Value Description
gpsLat INTEGER latitude multiplied with 10000000
gpsLon INTEGER longitude multiplied with 10000000
obdRpm INTEGER default is 0
obdSpeed INTEGER speed in km/h
obdItDistance INTEGER distance in meters
obdItTotalTime INTEGER trip total time
gpsTimestamp timestamp of the last coordinate (multiplied by 1000)
curl "https://api.ulu.io/ulu_endpoint"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -d "imei=IMEI
            &deviceId=DEVICE_ID
            &ts=TIMESTAMP
            &rssi=0
            &signalStrength=0
            &isFinished=1
            &values=VALUES"
        -X POST

on SUCCESS

{
    "success": true
}

GET Trip types

Get the trip_types (business, private, commute,…). The id is needed to change the trip_type_id on the trip. and on the vehicle.

curl "https://api.ulu.io/api/v1/trip_types"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>

uri = URI("https://api.ulu.io/api/v1/trip_types")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success":true,
    "errors":{},
    "trip_type": [
      {
        "id":1,
        "key": "private",
        "description":""
      },
      {
        "id":2,
        "key": "business",
        "description":""
      },
      {
        "id":3,
        "key": "commute",
        "description":""
      },
    ]
}

Trip Point

Name Value Description
id BIGINT This is the primary key of the table Trip Points, it represents uniqe key in table.
trip_id INTEGER This is the forenight key of the table Trips.
lon NUMERIC(10,7) DEFAULT 0.0 The longitude we get from dongle.
lat NUMERIC(10,7) DEFAULT 0.0 The latitude we get from dongle.
speed SMALL INT It is the reading from vehicle’s computer
country CHARACTER VARYING(15) The resolving country of the coordinats on OSM.
place CHARACTER VARYING(255) The resolving place of the coordinats on OSM.
road_name CHARACTER VARYING(255) The resolving road_name of the coordinats on OSM.
road_type CHARACTER VARYING(255) The resolving road_type of the coordinats on OSM.
speed_limit SMALL INT The resolving speed_limit of the coordinats on OSM.
distance INTEGER The distance on the point, reading from calculated values speed and time on dongle.
trip_obd_duration INTEGER The time on the point, reading from calculated values speed and time on dongle.
trip_idle_duration INTEGER The idle_time on the point, reading from calculated time on dongle.
fuel_level NUMERIC(5,3) The fuel on the point, reading from calculated values rpm, distance and speed on dongle.
rpm INTEGER DEFAULT 8 The reading of rpm on vehicle’s computer.
battery_voltage NUMERIC(5,3) The reading of battery voltage on vehicle’s computer.
created_at TIMESTAMP WITHOUT TIME ZONE The time when the event was created.
speeding_idx NUMERIC(6,2) DEFAULT 0.0 Percent of speeding. Calculated (speed/speed_limit).round(2)
distance_electric INTEGER DEFAULT 0 The distance on the point, reading from calculated values speed and time on dongle when car was driving in electric mode.
road_lon NUMERIC(10,7) DEFAULT 0.0 The resolving longitude of the coordinats on OSM.
road_lat NUMERIC(10,7) DEFAULT 0.0 The resolving latitude of the coordinats on OSM.
device_created_at TIMESTAMP WITHOUT TIME ZONE Timestamp when the event was created
acceleration SMALL INT If positive acceleration from previous point, if negative braking from previous point. The value is set only if the difference in speed is more (or equals) than 16 (or -16).
device_id BIGINT Identificator of device that the event was generated on
link_id BIGINT Id of HERE road resolvment
total_pages INT Total number of pages on the call of trip_points
current_page INT Current page on the call
has_more BOOLEAN Indicator if the call has more pages

GET Trip points

Old method Returns all the points for the given trip (ignores the ones that have no GPS locations)

New method To make API call you will need to give 3 parameters to the call:

URL Parameters

Parameter Description
TRIP_ID The ID of the car to retrieve
PAGE_NO Number of the page of the trip points (Starts with 1)
TOKEN Received token from the session response
(Optional) LIMIT_NO Default limit on the call is 100 records. If you want to receive more events in the call you can input this parameter. If the parameter is not inputed in the call the default number of events will be send.
curl "https://api.ulu.io/api/v1/trips/TRIP_ID/trip_points?page=PAGE_NO&limit=LIMIT_NO"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
require 'net/http'
require 'net/https'
require 'uri'
require 'json'

token = <TOKEN>
trip_id = <TRIP_ID>
page_no = 1 # Page always starts with 1 and so ->
limit_no = 100 # We can limit the number of the trip points that response will
               # return, default: 100

uri = URI("https://api.ulu.io/api/v1/trips/#{trip_id}/trip_points?page=#{page_no}&limit=#{limit_no}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri, {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' =>  "Token token=#{token}"
})
response = http.request request
puts response.body

on SUCCESS

{
    "success": true,
    "trip_points":
  [
    {
        "id": 121321,
        "trip_id": 32232,
        "lon": "5.6023166",
        "lat": "46.55555",
        "speed": 0,
        "country": "NL",
        "place": "Eindhoven ",
        "road_name": "High Tech Campus",
        "road_type": null,
        "speed_limit": 50,
        "distance": null,
        "trip_obd_duration": null,
        "trip_idle_duration": null,
        "fuel_level": "0.0",
        "rpm": 0,
        "battery_voltage": "0.0",
        "created_at": "2016-06-29T09:22:08.252+02:00",
        "speeding_idx": "0.0",
        "distance_electric": null,
        "road_lon": "14.60225",
        "road_lat": "46.14573",
        "device_created_at": "2016-06-29T09:14:22.637+02:00",
        "acceleration": 0,
        "device_id": 1377700228329,
        "link_id": 710391600
     }
  ],
    "total_pages": 16,
    "current_page": 1,
    "has_more": true
}

Hotspots

Name Value Description
id INTEGER This is the primary key of the table Ibuttons, it represents uniqe key in table.
user_id INTEGER Id of the user, that created the hotstpot
name CHARACTER VARYING(255) Name associated with hotspot
lon FLOAT DEFAULT 0.0 Longitude of the last location.
lat FLOAT DEFAULT 0.0 Latitude of the last location.
radius INTEGER Radius in meters, based on which a trip is connected to this hotspot. So if the start/stop is closer than the given radius, the hotspot will be associated with the trip
road_name CHARACTER VARYING(255) Street name of the address
road_place CHARACTER VARYING(255) Place of the address
road_country CHARACTER VARYING(255) ISO2 standard country code of the address
road_region CHARACTER VARYING(255) Zip code of the address
road_place CHARACTER VARYING(255) Place of the address
road_house_number INTEGER House number of the address
hotspot_type_id ENUMERATOR(1-9) Type of hotspot: 1 - home address, 2 - work address, 3 - private business address, 4 - business visit address, 5 - hotspot start address (like gas station, …), 6 - enroute location, 7 - business visit start/stop address, 9 - other
start_at TIMESTAMP WITHOUT TIME ZONE Deptecated
stop_at TIMESTAMP WITHOUT TIME ZONE Deprecated
deleted_at TIMESTAMP WITHOUT TIME ZONE When the created was deleted.
created_at TIMESTAMP WITHOUT TIME ZONE When the created was created.
updated_at TIMESTAMP WITHOUT TIME ZONE When the updated was updated.
entity_id INTEGER Id of the owner owner of the hotspot, polymorfic connection with entity type
entity_type CHARACTER VARYING(255) Owner of the hotspot type, polymorfic connection with entity id
is_point_of_interest BOOLEAN True if the hotspot is used as a point of interest
is_geofence BOOLEAN True if the hotspot is used also as a geofence
is_geofence_notify_in BOOLEAN If the hotspot is a geofence an this is set to true, a notification will be sent in case the vehicle enters inside the geofence
is_geofence_notify_out BOOLEAN If the hotspot is a geofence an this is set to true, a notification will be sent in case the vehicle gets out of the geofence
custom_permitted_vehicles BOOLEAN Is set to true, the hotspot will be connected only with a specific list of vehicles
remarks CHARACTER VARYING(255) Remarks/notes
house_number_extension CHARACTER VARYING(255) House number extension
show_on_map BOOLEAN If true, the hotspot can be displayed on the map on the ulu web app
visible_to ENUM(public,private,private_company) Hotspot visibility, public - can be seen by all users, private - can be seen only by the user that created it, private_company - can be seen by the user that created it and fleet admins
status_code CHARACTER VARYING(255) Deprecated
group_name CHARACTER VARYING(255) Groups associated with the hotspot
address CHARACTER VARYING(255) Full hotspot address (concatenated “road” values)
display_name CHARACTER VARYING(255) Name to display on the website

GET Hotspots

Get all company hotspots for the currently logged in user/company

curl "https://api.ulu.io/api/v1/hotspots?page=PAGE_NO&limit=LIMIT_NO"
        -H "Accept: application/json"
        -H "Content-Type: application/json"
        -H "Authorization: Token token=TOKEN"
        -X GET

on SUCCESS

{
  "success": true,
  "sort_value": "name",
  "sort_direction": "asc",
  "has_more": "false",
  "skip": 10000,
  "hotspots": [
    {
      "id": 140136,
      "user_id": 17034,
      "name": "ULU hq",
      "lon": "4.75054",
      "lat": "52.27688",
      "radius": 300,
      "road_name": "Boeingavenue",
      "road_place": "Schiphol-Rijk",
      "road_country": "NL",
      "road_zip_code": "1119PD",
      "road_region": "",
      "road_house_number": "241",
      "hotspot_type_id": 1,
      "start_at": null,
      "stop_at": null,
      "deleted_at": null,
      "created_at": "2019-12-02T13:09:46.437+01:00",
      "updated_at": "2019-12-02T13:09:46.437+01:00",
      "entity_id": 1566,
      "entity_type": "Company",
      "is_point_of_interest": true,
      "is_geofence": false,
      "is_geofence_notify_in": false,
      "is_geofence_notify_out": false,
      "custom_permitted_vehicles": false,
      "remarks": null,
      "house_number_extension": null,
      "show_on_map": false,
      "visible_to": "public",
      "status_code": null,
      "group_name": "",
      "address": "Boeingavenue 241 Schiphol-Rijk 1403AP NL",
      "display_name": "Boeingavenue 241 Schiphol-Rijk 1403AP NL"
    },...
  ]
}

URL Parameters

Parameter Description
page current page number; optional
limit maximum number records returned per page; optional
total_pages total number of pages that the pagination offers
current_page the current page the api calls are currently on
has_more if the request has more pages
sort_value deprecared
sort_direction deprecated
skip deprecated

FAQ

Here are common question from the clients. If you don’t find your answer you can contact us true our Support mail: support@ulu.io

Create and add user to fleet

Access token

    curl "https://api.ulu.io/api/v1/sessions"
        -H "Accept: application/json"
        -d "user[email]=EMAIL
            &user[password]=PASSWORD"

Next you need to find our access token from company user, so you can add user to the company. From email, you have receive administrators email and password. The response that you will receive will have access token so you could add user to our fleet. Parametres:

Creating user

    curl "https://api.ulu.io/api/v1/users"
        -H "Accept: application/json"
        -d "user[email]=EMAIL
            &user[password]=PASSWORD
            &user[sex]=SEX
            &user[name]=NAME
            &user[birthday]=BIRTHDAY
            &user[firstname]=FIRSTNAME
            &user[lastname]=LASTNAME
            &user[address]=ADDRESS
            &user[housenumber]=HOUSENUMBER
            &user[city]=CITY
            &user[phone]=PHONE
            &user[vat_number]=VAT_NUMBER
            &user[zip_code]=ZIP_CODE
            &user[post]=POST
            &user[country]=COUNTRY
            &user[timezone]=TIMEZONE"

First you will need to create user. The user needs following values:

Check what’s my company id

curl "https://api.ulu.io/api/v1/companies/me"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

Here you will get all the data for your company if you would like to add user to your company. We need those values to get this call:

Add to different company that i created

curl "https://api.ulu.io/api/v1/companies/"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

If you want to add user to different company that you created, you must first find it in the array of created companies. This call will get you an array of companies. For this call to work you must provide:

Adding user to the fleet

curl "https://api.ulu.io/api/v1/company_users"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -d "user[EMAIL]=USER_EMAIL"
           "company[id]=COMPANY_ID"

When you have user email and administrators access token, you can add user to your company. Parameters:

Adding vehicle on my company

First you need to check if the device that you want to assigned to vehicle is not already taken.

Access token

    curl "https://api.ulu.io/api/v1/sessions"
        -H "Accept: application/json"
        -d "user[email]=EMAIL
            &user[password]=PASSWORD"

First you need to find our access token from company user, so you can add user to the company. From email, you have receive administrators email and password. The response that you will receive will have access token so you could add user to our fleet. Parametres:

Check if device is updaired

curl "https://api.ulu.io/api/v1/devices?updaired=True"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

Next you check if the device is still unpaired from vehicle(you add ?updaired=True parameter in our call, if you only want to get devices that are not connected to any of the vehicle). If device is not connected to the vehicle then it will be in the response. Parameters:

Disconnect device from vehicle

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID/disconnect"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -X POST

With this call you will disconnect vehicle from the device. Device will no longer be on connected on the vehicle, but the vehicle will still be in your company, so you could see the trips and information about the vehicle. Parameters:

Reconnect device from vehicle

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -d "vehicle[DEVICE_ID]=NEW_VALUE
        -X put

With this call you will connect another device to an existing vehicle Parameters:

Finding company

curl "https://api.ulu.io/api/v1/companies/me"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

This call will return your current company. With this id you will add company to the vehicle. Parameters:

Add to different company

curl "https://api.ulu.io/api/v1/companies/"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

If you want to add vehicle to different company that you created, you must first find it in the array of created companies. This call will get you an array of companies. For this call to work you must provide:

Adding vehicle to the device

curl "https://api.ulu.io/api/v1/vehicles/"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -d "vehicle[odometer]=NEW_VALUE
            &vehicle[imei]=IMEI
            &vehicle[name]=NAME
            &vehicle[company_id]=COMPANY_ID
            &vehicle[license_plate]=LICENSE_PLATE
            &vehicle[vin]=VIN
            &vehicle[country]=COUNTRY"

At the end you create vehicle on your company. Parameters:

Assign user to the vehicle

Access token

    curl "https://api.ulu.io/api/v1/sessions"
        -H "Accept: application/json"
        -d "user[email]=EMAIL
            &user[password]=PASSWORD"

First you need to find our access token from company user, so you can add user to the company. From email, you have receive administrators email and password. The response that you will receive will have access token so you could add user to our fleet. Parametres:

Finding user

curl "https://api.ulu.io/api/v1/users"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

Next you get the user from the array of users in you company. You will need to find user’s id that you are trying to assign to the vehicle. Parameters:

Finding vehicle on your fleet

curl "https://api.ulu.io/api/v1/vehicles"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

Now you need to find vehicle on your fleet. In the response will be an array of vehicle’s that are connected to your fleet. Same as user you will need to find vehicle that you are trying to assign to user. Parameters:

Connecting vehicle and user (User is the owner of vehicle)

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -d "vehicle[owner_user_id]=USER_ID"
        -X PUT

To add user to the vehicle, you must assign him as owner of the vehicle. The user can then see his trips and check his vehicle data, … Parameters:

If you get successful response the user and vehicle will be connected.

Changing owner of the vehicle

    curl "https://api.ulu.io/api/v1/sessions"
        -H "Accept: application/json"
        -d "user[email]=EMAIL
            &user[password]=PASSWORD"

Access token

First you need to find our access token from company user, so you can add user to the company. From email, you have receive administrators email and password. The response that you will receive will have access token so you could add user to our fleet. Parametres:

curl "https://api.ulu.io/api/v1/vehicles"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

Finding vehicle on your fleet

Now you need to find vehicle on your fleet. In the response will be an array of vehicle’s that are connected to your fleet. Same as user you will need to find vehicle that you are trying to assign to user. Parameters:

curl "https://api.ulu.io/api/v1/users"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

Finding user - if new owner will be user

Next you get the user from the array of users in you company. You will need to find user’s id that you are trying to assign to the vehicle. Parameters:

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -d "vehicle[owner_user_id]=USER_ID"
        -X PUT

Changing owner of vehicle(User)

In the next call you will update new owner of the vehicle to the user that you selected before. Parameters:

Finding company - if new owner will be company

curl "https://api.ulu.io/api/v1/companies/me"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

This call will return your current company. With this id you will add company as the vehicle owner. Parameters:

Changing owner of vehicle(Company)

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -d "vehicle[owner_company_id]=COMPANY_ID"
        -X PUT

In the next call you will update new owner of the vehicle to the company that you selected before. Parameters:

Deleting vehicle from company

Access token

    curl "https://api.ulu.io/api/v1/sessions"
        -H "Accept: application/json"
        -d "user[email]=EMAIL
            &user[password]=PASSWORD"

First you need to find our access token from company user, so you can add user to the company. From email, you have receive administrators email and password. The response that you will receive will have access token so you could add user to our fleet. Parametres:

Finding vehicle on your fleet

curl "https://api.ulu.io/api/v1/vehicles"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"

Now you need to find vehicle on your fleet. In the response will be an array of vehicle’s that are connected to your fleet. Same as user you will need to find vehicle that you are trying to assign to user. Parameters:

Disconnect device from vehicle

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID/disconnect"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -X POST

With this call you will disconnect vehicle from the device. Device will no longer be on connected on the vehicle, but the vehicle will still be in your company, so you could see the trips and information about the vehicle. Parameters:

Deleting vehicle from your company

curl "https://api.ulu.io/api/v1/vehicles/VEHICLE_ID"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -X DELETE

With this call you will delete vehicle from your company. Device will be disconnected from vehicle, vehicle will no longer exist in your trip, and no trips will be seen for this vehicle. Parameters:

Deleting user from company

    curl "https://api.ulu.io/api/v1/sessions"
        -H "Accept: application/json"
        -d "user[email]=EMAIL
            &user[password]=PASSWORD"

Access token

First you need to find our access token from company user, so you can add user to the company. From email, you have receive administrators email and password. The response that you will receive will have access token so you could add user to our fleet. Parametres:

Finding user in your company

curl "https://api.ulu.io/api/v1/company_users"
     -H "Accept: application/json"
     -H "Authorization: Token token=TOKEN"

Here you will find the user witch you want to delete from your fleet. The id witch you will get here, you will need to remember for the next call. Parameters:

Deleting user from company

curl "https://api.ulu.io/api/v1/company_users/COMPANY_USER_ID"
        -H "Accept: application/json"
        -H "Authorization: Token token=TOKEN"
        -X DELETE

This will delete user from your fleet. Parameters:

Version 2.5 © ULU 2024