Skip to content

ao3_sync.api.client.AO3ApiClient

Bases: BaseSettings

AO3 API

Attributes:

Name Type Description
username str

AO3 username

password SecretStr

AO3 password

host str

AO3 host

requests_delay_seconds float | int

Delay between requests

output_dir str

Output directory

downloads_dir str

Downloads directory

use_history bool

Use history

history_filename str

History filename

debug bool

Debug mode

use_debug_cache bool

Use debug cache

debug_cache_dir str

Debug cache directory

auth property

Auth Api Instance

Returns:

Type Description
AuthApi

AuthApi Instance

bookmarks property

Bookmarks Api Instance

Returns:

Type Description
BookmarksApi

BookmarksApi Instance

series property

Series Api Instance

Returns:

Type Description
SeriesApi

SeriesApi Instance

works property

Works Api Instance

Returns:

Type Description
WorksApi

WorksApi Instance

download_file(relative_path)

Download a file from AO3

Parameters:

Name Type Description Default
relative_path str

Relative path to the file

required

Returns:

Type Description
str

File contents

fetch(*args, **kwargs)

Wrapper around requests.get that handles rate limiting and login

Parameters:

Name Type Description Default
*args Any

Positional arguments to pass to requests

()
**kwargs Any

Keyword arguments to pass to requests

{}

Returns:

Type Description
Response

Response object

Raises:

Type Description
RateLimitError

If the rate limit is exceeded

FailedRequest

If the request fails

get_debug_cache_dir()

Get the debug cache folder

Returns:

Type Description
Path

Debug cache folder

get_downloads_dir()

Get the downloads folder

Returns:

Type Description
Path

Downloads folder

get_history()

Get the internal API stats

Returns:

Type Description
dict

Stats

get_history_filepath()

Get the stats file path

Returns:

Type Description
Path

Stats file path

get_or_fetch(url, query_params=None, process_response=None, **kwargs)

Fetches a page and caches it if debug mode is enabled and use_debug_cache is True

Parameters:

Name Type Description Default
url str

URL to fetch

required
query_params dict

Query parameters

None
process_response Callable

Function to process the response

None
**kwargs Any

Keyword arguments to pass to requests

{}

Returns:

Type Description
str | bytes

Page contents

Raises:

Type Description
FailedRequest

If the request fails

get_output_dir()

Get the output folder

Returns:

Type Description
Path

Output folder

update_history(history)

Update the internal API stats

Parameters:

Name Type Description Default
data dict

Data to update

required