Linode REST API (v4) - 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:
API Features
* Access and Authentication via OAuth 2.0 (see:
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:
- 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
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
Great, congratulations !
Do you have intention to provide a Java Binding too, please ?
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.
Please include the reverse DNS within the instance reply (
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.
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 "
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
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.
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
It would be helpful for these to be consistently ordered, or for each to include a public/private indication with the
Thanks.