Skip to main content

The World Anvil API Python Client is a wrapper client designed to work with the Boromir API released by World Anvil on August 26, 2023. Please note that this client is currently a work in progress and may not have all features implemented. The World Anvil API enables users to interact with the World Anvil database by utilizing various API endpoints.

NOTE: If you find any issues feel free to open an issue and I will try to fix it.

The latest version compatible with Aragorn is 0.12.1. However, please be aware that the developer will not maintain the Aragorn version of the client. For Boromir, the latest version is recommended.

Latest

For the latest Boromir API Documentation, please visit:

Older Versions

The Aragorn API is deprecated and will be removed in the future. However, if needed, you can still access the Aragorn API Documentation here:

Table of Contents

Installation

The package is published on PyPI and can be installed with pip. To install, run:

pip --install pywaclient

Usage

Below is a simple example on how to use the endpoints:

import os
from pywaclient.api import BoromirApiClient

client = BoromirApiClient(
    '<YourScriptName>',
    '<link-to-your-website-or-bot-repository>',
    '<version>',
    os.environ['WA_APPLICATION_KEY'],
    os.environ['WA_AUTH_TOKEN']
)

# get your own user id. It is not possible to discover the user ids of other users via the API.
authenticated_user = client.user.identity()

# get the references to all the worlds on your account.
worlds = [world for world in client.user.worlds(authenticated_user['id'])]

# get the references to all the category on the first world.
categories = [category for category in client.world.categories(worlds[0]['id'])]

# gets a list of all the articles without a category in the first world
articles = [article for article in client.category.articles(worlds[0]['id'], '-1')]

# gets the full content of the first article
article = client.article.get(articles[0]['id'], 2)

# gets the full content of the first category. Categories and most other resources do not have a granularity of 2.
category = client.category.get(categories[0]['id'], 1)

# change the title of category
category = client.category.patch(category['id'], {
    'title': 'A New title'
})

# create a new category
new_category = client.category.put({
    'title': 'A New Category',
    'state': 'private',
    'world': {
        'id': worlds[0]['id']
    }
})

Endpoints

The BoromirApiClient class in the api.py file includes the following endpoints:

Endpoint con't.
/article /map
/block /markertype
/blockfolder /notebook
/blocktemplate /rpgsystem
/canvas /secret
/category /subscribergroup
/chronicle /timeline
/history /user
/image /variable_collection
/manuscript /world

Additionally, the endpoints directory contains several Python files each representing a specific endpoint of the World Anvil API. This includes articles, blocks, categories, histories, images, maps, secrets, timelines, users, worlds, and more. Each file contains a class with methods for interacting with the respective endpoint.

Exceptions

The exceptions.py file includes a series of exception classes to handle different types of errors:

Exception Class Description
WorldAnvilClientException Base exception class.
WorldAnvilServerException Unsuccessful server response.
ConnectionException Connection problem with the API server.
UnexpectedStatusException Unexpected status code from server.
InternalServerException Server responded with a 500 status.
UnauthorizedRequest The request was not authorized.
AccessForbidden Access to resource is forbidden.
ResourceNotFound The requested resource was not found.
UnprocessableDataProvided Unprocessable data was provided.
FailedRequest The request failed.

Each of these exception classes are used to handle specific types of errors that may arise when using the World Anvil API Python Client.

Classes

BoromirApiClient Class

The BoromirApiClient class is the central class in the file. It contains the headers and base URL for API communication. It also initializes the different API endpoints.

class BoromirApiClient:
    def __init__(self, name: str, url: str, version: str, application_key: str, authentication_token: str):
        self.headers = {
            'x-auth-token': authentication_token,
            'x-application-key': application_key,
            'Accept': 'application/json',
            'User-Agent': f'{name} ({url}, {version})'
        }
        self.headers_post = self.headers.copy()
        self.headers_post['Content-type'] = 'application/json'
        self.base_url = 'https://www.worldanvil.com/api/external/boromir/'
        self.article = ArticleCrudEndpoint(self)
        # etc.

BasicEndpoint Class

This class contains methods for making HTTP requests (GET, PUT, PATCH, POST, DELETE). These methods are used to interact with the API - fetch, create, update, and delete resources. After making a request, the _parse_response function is used to handle the response from the server.

class BasicEndpoint:
    def __init__(self, client: 'AragornApiClient', base_path: str):
        self.client = client
        self.path = base_path
    # etc.

CrudEndpoint Class

The CrudEndpoint class inherits from the BasicEndpoint class and provides methods for creating (PUT), updating (PATCH), and deleting (DELETE) resources.

class CrudEndpoint(BasicEndpoint):
    def __init__(self, client: 'AragornApiClient', base_path: str):
        super().__init__(client, base_path)
    # etc.

License

This project is licensed under the terms of the Apache 2.0 License. For complete details, refer to the license here.

Software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Metadata

Release files for pywaclient 1.7.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 pywaclient 1.7.0
File Size Uploaded
pywaclient-1.7.0.tar.gz 25.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pywaclient 1.7.0
File Interpreter ABI Platform
pywaclient-1.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 56.7 kB

Release files / pywaclient-1.7.0.tar.gz

Download URL pywaclient-1.7.0.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
932d07c0335d6b2b521e272e86a5f583caaf57c24c7257544e738f0f25cdfdf3
BLAKE2b-256 checksum
How to use checksums
bfc02ec1fa899f053b0f1bb3d1ef7a1ef9159c54e82518e71dc979fcde80e80e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release files / pywaclient-1.7.0-py3-none-any.whl

Download URL pywaclient-1.7.0-py3-none-any.whl
Size 31.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a083856a6754816b8b0a3145d52090d725c9184f5297cc796481a3c52b28f0a
BLAKE2b-256 checksum
How to use checksums
6e7805d50798e04348f2df2179024393fb5caaf26f81ec08a63518b90788da24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release history Release notifications | RSS feed

This release

1.7.0 This release

2 release files

1.6.8

2 release files

1.6.7

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.13

2 release files

1.1.12

2 release files

1.1.11

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

1 release file

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