Reply
Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

UCRM API

[ Edited ]

As of v.2.1.5 UCRM API is available. Go to http://docs.ucrm.apiary.io for guide and more details.

 

If you are using UCRM beta branch, go to http://docs.ucrmbeta.apiary.io since this guide reflects all new features and updates released in the current beta version.

 

-----------------------------------------------------------------------------------------------------------------

 

For now, the API is mostly intended to be used for mass-uploads / UCRM init, eg. create thousands of clients along with their services. 

 

We continue to work on API to provide you with more features: read and write, such as read service details to set up your own shaping or upload a payment from your own gateway.

Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

Re: UCRM API

As of version 2.1.7 there are few API enhancements:

 

 

  • You can upload invoices. The API enables you to mass import any previsous client's invoices. Note that the API for invoices is pretty simpified, no discounts or taxes can be imported neither asssociation to other UCRM entities can be created, such as products or services. You can just import simple invoice items. However this might be useful. See http://docs.ucrm.apiary.io/#reference/billing/invoice Note that we are also working on client's gallery and file uploads, so you will soon be able to import any pdf or pics into clients profile.

 

 

Please, share you thoughts and requests for improvements.

New Member
Posts: 12
Registered: ‎12-12-2016
Kudos: 13

Re: UCRM API

hi, i am having trouble getting the ucrm api to talk to our ucrm site.. It was working a few daysago.. now the UCRM Demo beta site is down.. for last 2 days with "502 bad gateway" error. can you pls help with any further info on how to use ucrm api ?
Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

Re: UCRM API

The ucrm demo is back online
New Member
Posts: 12
Registered: ‎12-12-2016
Kudos: 13

Re: UCRM API

thanks petr

New Member
Posts: 27
Registered: ‎07-21-2013
Kudos: 6

Re: UCRM API

Hi I'm new to the UCRM API and I was trying to retrieve something basic like the version name for my UCRM with the below script but I keep on getting

string(0) ""

after replacing "appKeyString" with my api. What could I be doing wrong based on the below

<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://ucrm.test.com/api/v1.0/version");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"X-Auth-App-Key: myapiis12345"
));

$response = curl_exec($ch);
curl_close($ch);

var_dump($response);
New Member
Posts: 36
Registered: ‎05-30-2014
Kudos: 35
Solutions: 5

Re: UCRM API

Is there any roadmap for creation of Sites or Devices? While it is possible to bulk import clients either through CSV or API, there does not appear to be a way to speed up Site and Device creation for building out the infrastructure.

Since most settings for devices can be retrieved during a sync, bulk device addition is a prime candidate, needing only a 7 basic attributes for an initial injection.
Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

Re: UCRM API

@CC_DKP this is not on our list because this would overlap with our other priority: integration with UNMS whose auto discovery tool would do the job also for UCRM.
New Member
Posts: 36
Registered: ‎05-30-2014
Kudos: 35
Solutions: 5

Re: UCRM API

Where is the best place to provide requests and feedback for the API?

 

I'm trying to tie UCRM into some of our daily tools, and would like access to be able to access the client_log.

Read only would be sufficient. If we could write (and have it show up as API or the API key name), that would be even better.

 

Something like /clients/id/log

 

which would return a list of objects with the following elements:

adminId: number

timestamp: string

message: string

 

(optional) adminFirstName 

(optional) adminLastName 

Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

Re: UCRM API

@CC_DKP sure, this sounds reasonable. We will upgrade the API.
Thanks for these suggestions.
Ubiquiti Employee
Posts: 1,043
Registered: ‎03-21-2016
Kudos: 164
Solutions: 120

Re: UCRM API

Hello @CC_DKP, API for client logs is available in 2.5.0-beta1. See the API docs for more information at http://docs.ucrmbeta.apiary.io/#reference/client-logs/get

New Member
Posts: 8
Registered: ‎07-04-2016
Kudos: 2

Re: UCRM API

Would you consider adding API Callbacks on creation, deletion, modification, etc of objects to aid in the development of interfaces to 3rd party systems like accounting packages (Quickbooks/(Online), Sage 50, etc) ?

Callbacks might implement a success/failure return to ensure consistency between the remote system and uCRM.

 

Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

Re: UCRM API

[ Edited ]

@PhaenyxWe could probably incorporate this but please, create a new feature request to help us prioritize it.

 

[Update]: The request is here: https://community.ubnt.com/t5/UCRM-Feature-Requests/API-Callbacks/idi-p/1961503 

Please, anyone who would need this, feel free to upvote it.

New Member
Posts: 36
Registered: ‎05-30-2014
Kudos: 35
Solutions: 5

Re: UCRM API

in 2.5.0-beta4, lookups for service-devices and service-surcharges by service ID both appear broken.

 

GET requests to /clients/services/###/service-devices (or service-surcharges), result in

 

No route found for \"GET /api/v1.0/clients/services/100/service-devices\": Method Not Allowed (Allow: POST)

Meanwhile, lookups based off the service-device ID work as expected.

 

That also brings up a good point. Without that api endpoint, there is no method I could find to enumerate service-device ids short of brute force. Would you consider adding a list of associated service-device ids to the data returned for service lookups? (/clients/services)

 

 

Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

Re: UCRM API

@CC_DKP we will look into that problem.

 

Regarding the number of service devices - what is the purpose of getting this number?

New Member
Posts: 36
Registered: ‎05-30-2014
Kudos: 35
Solutions: 5

Re: UCRM API

If the service-devices lookup by service is fixed, it isn't required, but it seems like /clients/services/service-devices/id is otherwise a fairly useless endpoint, as the serviceId is only exposed by service-devices and service-ips (which requires a serviceDeviceId or a similarly redundant serviceIpId to look up). Service-Ips are presented as part of a service request, but serviceDevices are not.

 

This came up as I was looking at a workflow that seemed like it required an excessive number of API calls to complete. Perhaps you could suggest a simpler method I am not seeing?

 

I want to look at a tower and determine how far each client is from it (or generally determine what tower a customer is attached to for the purpose of generating outage notifications during maintenance). Since I can find now path from the tower to the service, I have to start the search by enumerating all services then working back to the tower. The current workflow for this is:

 

  1. Request all services (/clients/services). Save addressGpsLat and addressGpsLon of the service along with service ID for each service in the system.
  2. Request all service-devices for the service (/clients/services/id/service-devices). Save interfaceId(s)
  3. Request each needed device-interface from step 2 (/devices/device-interfaces/id). Save deviceId
  4. Request each device from step 3 (/devices/id). save siteId. (Can cache alll devices with single request to /devices/)
  5. Request each site from step 4 (/sites/id). Get site name, gpsLat, gpsLon. (Can cache all sites with single request to /sites.)

To summarize, the shortest way I have discovered to find a site from service is service -> service-device -> device-interface -> device -> site, where only 2 of those requests can be cached.

 

Any suggestions?

 

Ubiquiti Employee
Posts: 1,043
Registered: ‎03-21-2016
Kudos: 164
Solutions: 120

Re: UCRM API

Hello @CC_DKP, the endpoints will be fixed in 2.5.1 hotfix release. Thank you for reporting the bug.

 

Your current workflow seems to be the most optimal way with current API.

New Member
Posts: 36
Registered: ‎05-30-2014
Kudos: 35
Solutions: 5

Re: UCRM API

On 2.5.1, testing the /invoices endpoint, I can't seem to be get the createdDateFrom and createdDateTo filters to work. they always appear to return all available invoices.

 

Python code:

 

def get_invoices_by_date(start, end):
    headers = {
        'X-Auth-App-Key': token
    }
    uri = server + '/invoices'
    data = {
        'createdDateFrom': start,
        'createdDateTo': end
    }
    response = requests.get(uri, headers=headers, data=data)
    return response.json()

get_invoices_by_date('2017-06-01','2017-06-30')

I'm not sure if I'm encoutering a bug in the API, or if I am just sending the data incorrectly (or I'm interpreting the documentation incorrectly).

 

 

Ubiquiti Employee
Posts: 3,173
Registered: ‎12-10-2015
Kudos: 1121
Solutions: 250

Re: UCRM API

@CC_DKP seems there is a bug indeed. Thanks for reporting.
New Member
Posts: 36
Registered: ‎05-30-2014
Kudos: 35
Solutions: 5

Re: UCRM API

Is there a good method for checking if a service is active?

 

If not, could I request a 'status' field be added to services returned by /clients/services, indicating their state (Active, ended, suspended, prepared, etc.)

 

Currently, /clients/services returns all services, even if the service has ended, or if the client they belong to was deactivated. Subsiquent requests depending on the service id  (such as /clients/services/id/service-devices) seem to be aware of the status, as the lookups error out.

 

I've tried using activeFrom, and activeTo, but they can sometimes be null, on both active and inactive services.

Reply