Linode REST API (v4) - Early Access

Linode Staff

Linode REST API - Early Access

What is the Linode REST API?

The Linode API v4 provides a programmatic interface into Linode services, allowing you to automate and manage all aspects of Linode instances, Backups, NodeBalancers, IP addresses, support tickets, your account settings, and so on. This new API is the foundation of upcoming features and products, including a new Linode Manager (more on that soon), command line interface, perhaps a mobile app, and bindings and developer tools.

API Documentation

Linode API v4 documentation is located here:

https://developers.linode.com/

API Features
* Access and Authentication via OAuth 2.0 (see: https://developers.linode.com/v4/access)

  • It's RESTful

  • Uniform / standard interface; standard HTTP verbs (GET, PUT, POST, DELETE)

  • Pagination of large results (see: https://developers.linode.com/v4/pagination)

  • Flexible query filtering (see: https://developers.linode.com/v4/filtering)

  • ITMCDISCTA - "If the Manager can do it, so can the API" (once we're done implementing)

  • Nested object results - fewer calls, probably just one call, to get all the information you want

  • Slugs rather than IDs for instance types, regions, distros, and kernels. These are static and won't ever change on you and will map to future instance type generations, etc.

  • Clean/Simple API Call Spec

  • Many "fast path" methods. For example: it's one API call to create a Linode, with a distribution, and have it boot

  • Manage Linode instances

  • Networking and IP information endpoints for IPv4 and IPv6, pools, and ranges

  • IP sharing (failover)

  • IP Assign (swap) endpoints

  • Manage Linode Backups (+snapshots)

  • Manage NodeBalancers

  • Support ticket endpoints

  • Graph data endpoints

  • Linode Manager users endpoints

  • Unified Events timeline replaces Host Job queue view and includes other events

  • and much more…

Bindings and Developer Tools
* Python Binding: https://github.com/linode/python-linode-api

  • CLI: https://github.com/linode/linode-cli

How can I help?

We'd very much appreciate any testing and feedback of this new API. To get access, go to cloud.linode.com and generate access tokens to use in your API clients.

Feedback is always appreciated! If you find a problem or have a suggestion, feel free to create a new forum thread in this category, or reply to this one, or submit a support ticket - whatever works.

Thanks,

-Chris

9 Replies

Hello,

Great, congratulations !

Do you have intention to provide a Java Binding too, please ?

Please, see: https://gitlab.com/cviniciusm/linode

I've started working on a PHP client for the Linode REST API (v4). Its available at https://github.com/idimensionz/linode-api-v4 . I've also started creating examples of how to use the API at https://github.com/idimensionz/linode-api-v4-examples .

What are options for unattended login, i.e. for orchestrations/provisioning scripts/applications? OAuth is not an option. I have tried personal access codes but failed.

What the documentation doesn't make clear, is that the API v4 does NOT work with the tokens generated by the old Linode Manager.

If you want to use API v4, you need to login to the NEW Linode Manager, which generates OAuth and also a new kind of personal tokens.

But, be warned, many scripts/apps don't support API v4, for example the Ansible linode module still requires IDs instead of Slugs and the old API v3 tokens.

feature request:

Please include the reverse DNS within the instance reply (https://api.linode.com/v4/linode/instances), it would help avoid extra requests.

for example, lets say I have a linode server with label "server1", I have to:

  • get /instances/, so I can get a list of all the servers

  • loop to get the id for "server1"

  • get the /instances/server1-id/ips to get a list of IPs with id and rdns

  • put /instances/server1-id/ips/ip-address with rdns content in the body

all of the above would be optimized like:

  • get /instances/server-label/ips/ip-address (if we could use the server label directly without an id)

  • put /instances/server-label/ips/ip-address with rnds content in the body

or

  • get /instances/, so I can get a list of all the servers, including rnds content

  • put /instances/server1-id/ips/ip-address with rnds content in the body

thank you.

PS:

I'm using an Ansible playbook, which is not very flexible with loops.

Hi all-

I can't get the python lib to work with Ubuntu 16.04.2 LTS.

Fresh install of OS, and used pip to install linode-api module (enum34 and httplib2 mods are installed).

Created my Personal Access token using the link on the developer page.. i.e. cloud.linode.com.

This works..

import linode

client = linode.LinodeClient('my-oauth-token')

but next step gives errors.. (tried spacing/indents differently and using "python -tt" )

for r in client.get_regions():

… print(r.label)

Traceback (most recent call last):

File "", line 2, in File "/usr/local/lib/python2.7/dist-packages/linode/objects/base.py", line 122, in getattribute

return object.getattribute(self, name)

AttributeError: 'Region' object has no attribute 'label'

>

Please let me know what i need to do to make this work.

-TIA

So, I've been playing with half a day. It's probably good to create panel like Linode Manager but though to setup few linodes using ansible.

  • What is the reason for keeping page 25 items long? Are you trying to save bandwidth? To list everything you need to query API multiple times.

  • I wanted to create linode with specific disk configuration. I cannot specify any disks while POSTing /instances so I'm using POST /instances/{id}/disks

However each time I get response "Linode busy"

I end up with following solution which is pretty hacky and bloated:

- name: Create distro disk
  uri:
    url: https://api.linode.com/v4/linode/instances/{{ instance.json.id }}/disks
    method: POST
    body: "{
            'size': 3000,
            'authorized_keys': {{ pub_key }},
            'distribution': '{{ distribution }}',
            'root_pass': '{{ lookup('password', '/dev/null length=64 chars=ascii_letters') }}'
          }"
    headers:
      Content-Type: application/json
      Authorization: "Bearer {{ access_token }}"
    body_format: json
    return_content: yes
  when: instance|success
  register: volume_sys
  until: volume_sys.content.find("Linode busy") == -1
  retries: 10
  delay: 2

Instead of using retries/delay I'd rather like REST call to wait as long as necessary.

When using https://api.linode.com/v4/linode/instances : The ordering of the ipv4[] addresses is inconsistent.

ie:

Sometimes the public ip is listed as ipv4[0], and the private ip is listed as ipv4[1]

Other times the public ip is listed as ipv4[1], and the private ip is listed as ipv4[0]

This CAN be resolved by making a separate API hit to https://api.linode.com/v4/linode/instan … odeID>/ips">https://api.linode.com/v4/linode/instances//ips. However that is wasteful of network traffic, considering that the info could have been ordered clearly in the original return.

It would be helpful for these to be consistently ordered, or for each to include a public/private indication with the https://api.linode.com/v4/linode/instances return.

Thanks.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct