Skip to main content

linode_api4

The official python library for the Linode API v4 in python.

https://img.shields.io/github/actions/workflow/status/linode/linode_api4-python/main.yml?label=tests https://badge.fury.io/py/linode-api4.svg Documentation Status

Installation

pip install linode_api4

Building from Source

To build and install this package:

  • Clone this repository

  • python3 -m pip install .

Usage

Quick Start

In order to authenticate with the Linode API, you will first need to create a Linode Personal Access Token with your desired account permissions.

The following code sample can help you quickly get started using this package.

from linode_api4 import LinodeClient, Instance

# Create a Linode API client
client = LinodeClient("MY_PERSONAL_ACCESS_TOKEN")

# Create a new Linode
new_linode, root_pass = client.linode.instance_create(
    ltype="g6-nanode-1",
    region="us-southeast",
    image="linode/ubuntu22.04",
    label="my-ubuntu-linode"
)

# Print info about the Linode
print("Linode IP:", new_linode.ipv4[0])
print("Linode Root Password:", root_pass)

# List all Linodes on the account
my_linodes = client.linode.instances()

# Print the Label of every Linode on the account
print("All Instances:")
for instance in my_linodes:
    print(instance.label)

# List Linodes in the us-southeast region
specific_linodes = client.linode.instances(
    Instance.region == "us-southeast"
)

# Print the label of each Linode in us-southeast
print("Instances in us-southeast:")
for instance in specific_linodes:
    print(instance.label)

# Delete the new instance
new_linode.delete()

Check out the Getting Started guide for more details on getting started with this library, or read the docs for more extensive documentation.

Examples

See the Install on a Linode example project for a simple use case demonstrating many of the features of this library.

Contributing

Tests

Tests live in the test directory. When invoking tests, make sure you are in the root directory of this project. Install unit-test dependencies and run the mocked unit suite with:

python3 -m pip install -e ".[unit-test]"
make test-unit

The test suite uses fixtures stored as JSON in test/fixtures. These files contain sanitized JSON responses from the API - the file name is the URL called to produce the response, replacing any slashes with underscores.

Test classes should extend test.base.ClientBaseCase. This provides them with self.client, a LinodeClient object that is set up to work with tests. Importantly, any GET request made by this object will be mocked to retrieve data from the test fixtures. This includes lazy-loaded objects using this client (and by extension related models).

When testing against requests other than GET requests, self.mock_post (and equivalent methods for other HTTP verbs) can be used in a with block to mock out the intended request type. These functions accept the relative path from the api base url that should be returned, for example:

# this should return the result of GET /linode/instances/123
with self.mock_post('/linode/instances/123'):
  linode = self.client.linode.instance_create('g6-standard-2', 'us-east')
  self.assertEqual(linode.id, 123) # passes

Integration Tests

Integration tests live in the test/integration directory.

Pre-requisite

Export Linode API token as LINODE_TOKEN before running integration tests:

export LINODE_TOKEN = $(your_token)

Running the tests

Run the tests locally using the make command. Run the entire test suite using command below:

make test-int

To run a specific package/suite, use the environment variable TEST_SUITE using directory names in integration/… folder

make TEST_SUITE="account" test-int          // Runs tests in `integration/models/account` directory
make TEST_SUITE="linode_client" test-int    // Runs tests in `integration/linode_client` directory

Lastly to run a specific test case use environment variable TEST_CASE with test-int command:

make TEST_CASE=test_get_domain_record test-int

Documentation

This library is documented with Sphinx. Docs live in the docs directory. The easiest way to build the docs is to run sphinx-autobuild in that folder:

sphinx-autobuild docs docs/build

After running this command, sphinx-autobuild will host a local web server with the rendered documentation.

Classes and functions inside the library should be annotated with sphinx-compliant docstrings which will be used to automatically generate documentation for the library. When contributing, be sure to update documentation or include new docstrings where applicable to keep the library’s documentation up to date and useful.

Missing or inaccurate documentation is a bug. If you notice that the documentation for this library is out of date or unclear, please open an issue to make us aware of the problem.

Contributing

Please follow the Contributing Guidelines when making a contribution.

Metadata

Release files for linode-api4 5.48.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linode-api4 5.48.0
File Size Uploaded
linode_api4-5.48.0.tar.gz 291.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for linode-api4 5.48.0
File Interpreter ABI Platform
linode_api4-5.48.0-py3-none-any.whl Python 3 none any Details

Total release size: 452.0 kB

Release files / linode_api4-5.48.0.tar.gz

Download URL linode_api4-5.48.0.tar.gz
Size 291.3 kB
Tags Source
SHA-256 checksum
How to use checksums
055b854b5d9454ffbda30d579e7d4ebc2a4b9e4e9f1db24c770ebca864fbfdcb
BLAKE2b-256 checksum
How to use checksums
9a5ed9ca973274a831ab06640358dad0dce5e2cddadfb1203188c7d2aa2a85e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / linode_api4-5.48.0-py3-none-any.whl

Download URL linode_api4-5.48.0-py3-none-any.whl
Size 160.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b93ea24c6b4507ecd28ae28a049c7c6e5b01fec4b0af8385ff713779ce3d4fb
BLAKE2b-256 checksum
How to use checksums
efb6d670763f1a09975b2290e49ff36adf12eecc842dd44e8b002557d9130ec3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

5.48.0 This release

2 release files

5.47.0

2 release files

5.46.0

2 release files

5.45.0

2 release files

5.44.0

2 release files

5.43.0

2 release files

5.42.0

2 release files

5.41.0

2 release files

5.39.0

2 release files

5.38.0

2 release files

5.34.0

2 release files

5.33.1

2 release files

5.32.0

2 release files

5.31.0

2 release files

5.30.0

2 release files

5.29.1

2 release files

5.29.0

2 release files

5.25.0

2 release files

5.24.0

2 release files

5.23.0

2 release files

5.22.0

2 release files

5.21.0

2 release files

5.20.0

2 release files

5.19.0

2 release files

5.18.0

2 release files

5.17.0

2 release files

5.15.1

2 release files

5.15.0

2 release files

5.11.0

2 release files

5.9.0

2 release files

5.8.0

2 release files

5.7.2

2 release files

5.7.1

2 release files

5.7.0

2 release files

5.6.0

2 release files

5.5.1

2 release files

5.5.0

2 release files

5.4.1

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.1

2 release files

5.2.0

2 release files

5.1.2

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.0.0

2 release files

3.0.5

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.3.6

2 release files

2.3.5

2 release files

2.3.4

2 release files

2.3.3

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page