wp_api.endpoints package

Submodules

wp_api.endpoints.base module

Base class for WordPress REST API endpoints

class wp_api.endpoints.base.BaseEndpoint(client)[source]

Bases: object

Base class for WordPress REST API endpoints

endpoint = None
__init__(client)[source]

Initialize the endpoint with a client instance

Parameters:

client – WordPress API client instance

list(**params)[source]

Get a list of items from this endpoint

Parameters:

**params – Query parameters to include in the request

Return type:

List[Dict]

Returns:

List of items

get(id, **params)[source]

Get a single item by ID

Parameters:
  • id (int) – Item ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Item data

create(data)[source]

Create a new item

Parameters:

data (Dict) – Item data

Return type:

Dict

Returns:

Created item data

update(id, data)[source]

Update an existing item

Parameters:
  • id (int) – Item ID

  • data (Dict) – Item data to update

Return type:

Dict

Returns:

Updated item data

delete(id, **params)[source]

Delete an item

Parameters:
  • id (int) – Item ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Deleted item data

wp_api.endpoints.block_patterns module

Block Patterns endpoint for the WordPress REST API (available in WordPress 5.8+)

class wp_api.endpoints.block_patterns.BlockPatterns(client)[source]

Bases: BaseEndpoint

WordPress Block Patterns API wrapper

__init__(client)[source]

Initialize the block patterns endpoint with a client instance

Parameters:

client – WordPress API client instance

list(**params)[source]

Get all registered block patterns

Parameters:

**params – Query parameters to include in the request

Return type:

List[Dict]

Returns:

List of block patterns

get_categories(**params)[source]

Get all registered block pattern categories

Parameters:

**params – Query parameters to include in the request

Return type:

List[Dict]

Returns:

List of block pattern categories

wp_api.endpoints.categories module

Categories endpoint for the WordPress REST API

class wp_api.endpoints.categories.Categories(client)[source]

Bases: BaseEndpoint

WordPress Categories API wrapper

endpoint = 'categories'
list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, parent=None, post=None, slug=None, **kwargs)[source]

List categories with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, slug, etc.)

  • hide_empty (bool) – Whether to hide categories that don’t have any posts

  • parent (int) – Limit result set to categories that have a specific parent ID

  • post (int) – Limit result set to categories assigned to a specific post

  • slug (Union[str, List[str]]) – Limit result set to categories with one or more specific slugs

Return type:

List[Dict]

Returns:

List of categories

create(name, slug=None, parent=None, description=None, **kwargs)[source]

Create a new category

Parameters:
  • name (str) – Name of the category

  • slug (str) – Slug for the category (optional)

  • parent (int) – Parent category ID (optional)

  • description (str) – Description of the category (optional)

Return type:

Dict

Returns:

Created category data

update(id, name=None, slug=None, parent=None, description=None, **kwargs)[source]

Update an existing category

Parameters:
  • id (int) – Category ID

  • name (str) – Name of the category (optional)

  • slug (str) – Slug for the category (optional)

  • parent (int) – Parent category ID (optional)

  • description (str) – Description of the category (optional)

Return type:

Dict

Returns:

Updated category data

wp_api.endpoints.comments module

Comments endpoint for the WordPress REST API

class wp_api.endpoints.comments.Comments(client)[source]

Bases: BaseEndpoint

WordPress Comments API wrapper

endpoint = 'comments'
list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, author_email=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date_gmt', parent=None, parent_exclude=None, post=None, status='approve', type='comment', password=None, **kwargs)[source]

List comments with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to comments published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to comments assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes comments assigned to specific authors

  • author_email (str) – Limit result set to comments with a specific author email

  • before (str) – Limit response to comments published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, id, include, post, parent, type)

  • parent (Union[int, List[int]]) – Limit result set to comments with specific parent IDs

  • parent_exclude (Union[int, List[int]]) – Limit result set to all items except those with specific parent IDs

  • post (Union[int, List[int]]) – Limit result set to comments assigned to specific posts

  • status (str) – Limit result set to comments with a specific status (approve, hold, spam, trash)

  • type (str) – Limit result set to comments with a specific type (comment, pingback, trackback)

  • password (str) – Filter comments by post password, if the post is password protected

Return type:

List[Dict]

Returns:

List of comments

create(post, content, author=None, author_name=None, author_email=None, author_url=None, parent=None, status=None, **kwargs)[source]

Create a new comment

Parameters:
  • post (int) – Post ID to which the comment belongs

  • content (str) – Content of the comment

  • author (int) – User ID of the comment author (if registered)

  • author_name (str) – Name of the comment author (if not registered)

  • author_email (str) – Email of the comment author (if not registered)

  • author_url (str) – URL/website of the comment author (if not registered)

  • parent (int) – Parent comment ID (for threaded comments)

  • status (str) – Comment status (approve, hold, spam, trash)

Return type:

Dict

Returns:

Created comment data

update(id, content=None, author=None, author_name=None, author_email=None, author_url=None, post=None, parent=None, status=None, **kwargs)[source]

Update an existing comment

Parameters:
  • id (int) – Comment ID

  • content (str) – Content of the comment

  • author (int) – User ID of the comment author (if registered)

  • author_name (str) – Name of the comment author (if not registered)

  • author_email (str) – Email of the comment author (if not registered)

  • author_url (str) – URL/website of the comment author (if not registered)

  • post (int) – Post ID to which the comment belongs

  • parent (int) – Parent comment ID (for threaded comments)

  • status (str) – Comment status (approve, hold, spam, trash)

Return type:

Dict

Returns:

Updated comment data

wp_api.endpoints.custom_fields module

Custom fields (post meta) endpoint for the WordPress REST API

class wp_api.endpoints.custom_fields.CustomFields(client, post_type='posts')[source]

Bases: BaseEndpoint

WordPress Custom Fields (post meta) API wrapper

Parameters:

post_type (str)

__init__(client, post_type='posts')[source]

Initialize the custom fields endpoint with a client instance and post type

Parameters:
  • client – WordPress API client instance

  • post_type (str) – Post type (posts, pages, or custom post type)

get_all(post_id, **params)[source]

Get all custom fields (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Post meta data

get(post_id, meta_key, **params)[source]

Get a specific custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_key (str) – Meta key

  • **params – Query parameters to include in the request

Return type:

Any

Returns:

Meta value

create(post_id, meta_key, meta_value)[source]

Create a new custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_key (str) – Meta key

  • meta_value (Any) – Meta value

Return type:

Dict

Returns:

Created meta data

update(post_id, meta_id, meta_value)[source]

Update an existing custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_id (int) – Meta ID

  • meta_value (Any) – New meta value

Return type:

Dict

Returns:

Updated meta data

delete(post_id, meta_id, force=True)[source]

Delete a custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_id (int) – Meta ID

  • force (bool) – Whether to bypass the trash and force deletion

Return type:

Dict

Returns:

Deleted meta data

update_or_create(post_id, meta_key, meta_value)[source]

Update an existing custom field or create if it doesn’t exist

Parameters:
  • post_id (int) – Post ID

  • meta_key (str) – Meta key

  • meta_value (Any) – Meta value

Return type:

Dict

Returns:

Updated or created meta data

wp_api.endpoints.custom_post_types module

Custom Post Types support for the WordPress REST API

class wp_api.endpoints.custom_post_types.CustomPostType(client, post_type)[source]

Bases: BaseEndpoint

WordPress Custom Post Type API wrapper

Parameters:

post_type (str)

__init__(client, post_type)[source]

Initialize the custom post type endpoint with a client instance

Parameters:
  • client – WordPress API client instance

  • post_type (str) – Custom post type slug (e.g., ‘product’, ‘portfolio’, etc.)

list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', slug=None, status='publish', **kwargs)[source]

List custom post type items with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to posts published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to posts assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes posts assigned to specific authors

  • before (str) – Limit response to posts published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • slug (Union[str, List[str]]) – Limit result set to posts with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to posts with specific statuses

Return type:

List[Dict]

Returns:

List of custom post type items

get(id, **params)[source]

Get a single custom post type item by ID

Parameters:
  • id (int) – Item ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Custom post type item data

create(title, content=None, status='publish', **kwargs)[source]

Create a new custom post type item

Parameters:
  • title (str) – Item title

  • content (str) – Item content

  • status (str) – Item status (publish, future, draft, pending, private)

  • **kwargs – Additional item data

Return type:

Dict

Returns:

Created custom post type item data

update(id, title=None, content=None, status=None, **kwargs)[source]

Update an existing custom post type item

Parameters:
  • id (int) – Item ID

  • title (str) – Item title

  • content (str) – Item content

  • status (str) – Item status (publish, future, draft, pending, private)

  • **kwargs – Additional item data to update

Return type:

Dict

Returns:

Updated custom post type item data

delete(id, force=False)[source]

Delete a custom post type item

Parameters:
  • id (int) – Item ID

  • force (bool) – Whether to bypass the trash and force deletion

Return type:

Dict

Returns:

Deleted custom post type item data

get_meta()[source]

Get a custom fields handler for this custom post type

Returns:

CustomFields endpoint handler for this custom post type

wp_api.endpoints.media module

Media endpoint for the WordPress REST API

class wp_api.endpoints.media.Media(client)[source]

Bases: BaseEndpoint

WordPress Media API wrapper

endpoint = 'media'
list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', parent=None, parent_exclude=None, slug=None, status='inherit', media_type=None, mime_type=None, **kwargs)[source]

List media items with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to media items published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to media items assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes media items assigned to specific authors

  • before (str) – Limit response to media items published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • parent (Union[int, List[int]]) – Limit result set to items with specific parent IDs

  • parent_exclude (Union[int, List[int]]) – Limit result set to all items except those with specific parent IDs

  • slug (Union[str, List[str]]) – Limit result set to media items with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to media items with specific statuses

  • media_type (str) – Limit result set to media items with a specific media type

  • mime_type (str) – Limit result set to media items with a specific MIME type

Return type:

List[Dict]

Returns:

List of media items

upload(file_data, file_name=None, title=None, caption=None, description=None, alt_text=None, **kwargs)[source]

Upload a new media file

Parameters:
  • file_data (BinaryIO) – File data (file-like object in binary mode)

  • file_name (str) – Name of the file

  • title (str) – Title for the media item

  • caption (str) – Caption for the media item

  • description (str) – Description for the media item

  • alt_text (str) – Alternative text for the media item

Return type:

Dict

Returns:

Created media item data

update(id, title=None, caption=None, description=None, alt_text=None, **kwargs)[source]

Update an existing media item

Parameters:
  • id (int) – Media item ID

  • title (str) – Title for the media item

  • caption (str) – Caption for the media item

  • description (str) – Description for the media item

  • alt_text (str) – Alternative text for the media item

Return type:

Dict

Returns:

Updated media item data

wp_api.endpoints.pages module

Pages endpoint for the WordPress REST API

class wp_api.endpoints.pages.Pages(client)[source]

Bases: BaseEndpoint

WordPress Pages API wrapper

endpoint = 'pages'
list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, menu_order=None, offset=None, order='desc', orderby='date', parent=None, parent_exclude=None, slug=None, status='publish', **kwargs)[source]

List pages with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to pages published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to pages assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes pages assigned to specific authors

  • before (str) – Limit response to pages published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • menu_order (int) – Limit result set to pages with a specific menu_order value

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • parent (Union[int, List[int]]) – Limit result set to items with particular parent IDs

  • parent_exclude (Union[int, List[int]]) – Limit result set to all items except those with specific parent IDs

  • slug (Union[str, List[str]]) – Limit result set to pages with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to pages with specific statuses

Return type:

List[Dict]

Returns:

List of pages

create(title, content=None, excerpt=None, status='publish', author=None, featured_media=None, comment_status=None, ping_status=None, menu_order=None, parent=None, template=None, **kwargs)[source]

Create a new page

Parameters:
  • title (str) – Page title

  • content (str) – Page content

  • excerpt (str) – Page excerpt

  • status (str) – Page status (publish, future, draft, pending, private)

  • author (int) – Page author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • menu_order (int) – The order in which the page should appear in menus

  • parent (int) – Parent page ID

  • template (str) – Page template to use

Return type:

Dict

Returns:

Created page data

update(id, title=None, content=None, excerpt=None, status=None, author=None, featured_media=None, comment_status=None, ping_status=None, menu_order=None, parent=None, template=None, **kwargs)[source]

Update an existing page

Parameters:
  • id (int) – Page ID

  • title (str) – Page title

  • content (str) – Page content

  • excerpt (str) – Page excerpt

  • status (str) – Page status (publish, future, draft, pending, private)

  • author (int) – Page author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • menu_order (int) – The order in which the page should appear in menus

  • parent (int) – Parent page ID

  • template (str) – Page template to use

Return type:

Dict

Returns:

Updated page data

get_revisions(page_id, **params)[source]

Get page revisions

Parameters:
  • page_id (int) – Page ID

  • **params – Query parameters

Return type:

List[Dict]

Returns:

List of page revisions

get_revision(page_id, revision_id, **params)[source]

Get a specific page revision

Parameters:
  • page_id (int) – Page ID

  • revision_id (int) – Revision ID

  • **params – Query parameters

Return type:

Dict

Returns:

Page revision data

wp_api.endpoints.posts module

Posts endpoint for the WordPress REST API

class wp_api.endpoints.posts.Posts(client)[source]

Bases: BaseEndpoint

WordPress Posts API wrapper

endpoint = 'posts'
list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', slug=None, status='publish', categories=None, categories_exclude=None, tags=None, tags_exclude=None, sticky=None, tax_relation=None, **kwargs)[source]

List posts with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to posts published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to posts assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes posts assigned to specific authors

  • before (str) – Limit response to posts published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • slug (Union[str, List[str]]) – Limit result set to posts with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to posts with specific statuses

  • categories (Union[int, List[int]]) – Limit result set to items with specific categories

  • categories_exclude (Union[int, List[int]]) – Limit result set to items without specified categories

  • tags (Union[int, List[int]]) – Limit result set to items with specific tags

  • tags_exclude (Union[int, List[int]]) – Limit result set to items without specific tags

  • sticky (bool) – Limit result set to items that are sticky

  • tax_relation (str) – Taxonomy relationship (AND/OR)

Return type:

List[Dict]

Returns:

List of posts

create(title, content=None, excerpt=None, status='publish', author=None, featured_media=None, comment_status=None, ping_status=None, format=None, categories=None, tags=None, **kwargs)[source]

Create a new post

Parameters:
  • title (str) – Post title

  • content (str) – Post content

  • excerpt (str) – Post excerpt

  • status (str) – Post status (publish, future, draft, pending, private)

  • author (int) – Post author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • format (str) – Post format (standard, aside, chat, gallery, link, image, quote, status, video, audio)

  • categories (List[int]) – List of category IDs

  • tags (List[int]) – List of tag IDs

Return type:

Dict

Returns:

Created post data

update(id, title=None, content=None, excerpt=None, status=None, author=None, featured_media=None, comment_status=None, ping_status=None, format=None, categories=None, tags=None, **kwargs)[source]

Update an existing post

Parameters:
  • id (int) – Post ID

  • title (str) – Post title

  • content (str) – Post content

  • excerpt (str) – Post excerpt

  • status (str) – Post status (publish, future, draft, pending, private)

  • author (int) – Post author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • format (str) – Post format (standard, aside, chat, gallery, link, image, quote, status, video, audio)

  • categories (List[int]) – List of category IDs

  • tags (List[int]) – List of tag IDs

Return type:

Dict

Returns:

Updated post data

get_revisions(post_id, **params)[source]

Get post revisions

Parameters:
  • post_id (int) – Post ID

  • **params – Query parameters

Return type:

List[Dict]

Returns:

List of post revisions

get_revision(post_id, revision_id, **params)[source]

Get a specific post revision

Parameters:
  • post_id (int) – Post ID

  • revision_id (int) – Revision ID

  • **params – Query parameters

Return type:

Dict

Returns:

Post revision data

wp_api.endpoints.settings module

Settings endpoint for the WordPress REST API

class wp_api.endpoints.settings.Settings(client)[source]

Bases: BaseEndpoint

WordPress Settings API wrapper

endpoint = 'settings'
get(**params)[source]

Get all settings

Parameters:

**params – Query parameters to include in the request

Return type:

Dict[str, Any]

Returns:

Dictionary of settings

update(**settings)[source]

Update settings

Parameters:

**settings – Settings to update as keyword arguments

Return type:

Dict[str, Any]

Returns:

Updated settings

wp_api.endpoints.tags module

Tags endpoint for the WordPress REST API

class wp_api.endpoints.tags.Tags(client)[source]

Bases: BaseEndpoint

WordPress Tags API wrapper

endpoint = 'tags'
list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, post=None, slug=None, **kwargs)[source]

List tags with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, slug, etc.)

  • hide_empty (bool) – Whether to hide tags that don’t have any posts

  • post (int) – Limit result set to tags assigned to a specific post

  • slug (Union[str, List[str]]) – Limit result set to tags with one or more specific slugs

Return type:

List[Dict]

Returns:

List of tags

create(name, slug=None, description=None, **kwargs)[source]

Create a new tag

Parameters:
  • name (str) – Name of the tag

  • slug (str) – Slug for the tag (optional)

  • description (str) – Description of the tag (optional)

Return type:

Dict

Returns:

Created tag data

update(id, name=None, slug=None, description=None, **kwargs)[source]

Update an existing tag

Parameters:
  • id (int) – Tag ID

  • name (str) – Name of the tag (optional)

  • slug (str) – Slug for the tag (optional)

  • description (str) – Description of the tag (optional)

Return type:

Dict

Returns:

Updated tag data

wp_api.endpoints.taxonomies module

Taxonomies endpoint for the WordPress REST API

class wp_api.endpoints.taxonomies.Taxonomies(client)[source]

Bases: BaseEndpoint

WordPress Taxonomies API wrapper

endpoint = 'taxonomies'
list(**params)[source]

Get all registered taxonomies

Parameters:

**params – Query parameters to include in the request

Return type:

Dict[str, Dict]

Returns:

Dictionary of taxonomies

get(taxonomy, **params)[source]

Get a specific taxonomy

Parameters:
  • taxonomy (str) – Taxonomy slug (e.g., ‘category’, ‘post_tag’)

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Taxonomy data

class wp_api.endpoints.taxonomies.Terms(client, taxonomy)[source]

Bases: BaseEndpoint

Base class for taxonomy terms endpoints

Parameters:

taxonomy (str)

__init__(client, taxonomy)[source]

Initialize the terms endpoint with a client instance and taxonomy

Parameters:
  • client – WordPress API client instance

  • taxonomy (str) – Taxonomy slug (e.g., ‘category’, ‘post_tag’)

list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, parent=None, post=None, slug=None, **kwargs)[source]

List taxonomy terms with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, slug, etc.)

  • hide_empty (bool) – Whether to hide terms that don’t have any posts

  • parent (int) – Limit result set to terms that have a specific parent ID

  • post (int) – Limit result set to terms assigned to a specific post

  • slug (Union[str, List[str]]) – Limit result set to terms with one or more specific slugs

Return type:

List[Dict]

Returns:

List of terms

get(id, **params)[source]

Get a specific term

Parameters:
  • id (int) – Term ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Term data

create(name, slug=None, description=None, parent=None, meta=None, **kwargs)[source]

Create a new term

Parameters:
  • name (str) – Term name

  • slug (str) – Term slug

  • description (str) – Term description

  • parent (int) – Parent term ID

  • meta (Dict) – Term meta data

Return type:

Dict

Returns:

Created term data

update(id, name=None, slug=None, description=None, parent=None, meta=None, **kwargs)[source]

Update an existing term

Parameters:
  • id (int) – Term ID

  • name (str) – Term name

  • slug (str) – Term slug

  • description (str) – Term description

  • parent (int) – Parent term ID

  • meta (Dict) – Term meta data

Return type:

Dict

Returns:

Updated term data

delete(id, force=False)[source]

Delete a term

Parameters:
  • id (int) – Term ID

  • force (bool) – Whether to bypass the trash and force deletion

Return type:

Dict

Returns:

Deleted term data

wp_api.endpoints.users module

Users endpoint for the WordPress REST API

class wp_api.endpoints.users.Users(client)[source]

Bases: BaseEndpoint

WordPress Users API wrapper

endpoint = 'users'
list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, offset=None, order='asc', orderby='name', slug=None, roles=None, **kwargs)[source]

List users with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, registered_date, etc.)

  • slug (Union[str, List[str]]) – Limit result set to users with one or more specific slugs

  • roles (Union[str, List[str]]) – Limit result set to users matching at least one specific role

Return type:

List[Dict]

Returns:

List of users

create(username, email, password, name=None, first_name=None, last_name=None, description=None, url=None, roles=None, **kwargs)[source]

Create a new user (requires proper authentication with user creation capabilities)

Parameters:
  • username (str) – Username for the user

  • email (str) – Email address for the user

  • password (str) – Password for the user

  • name (str) – Display name for the user

  • first_name (str) – First name for the user

  • last_name (str) – Last name for the user

  • description (str) – Description/bio for the user

  • url (str) – URL/website for the user

  • roles (List[str]) – List of roles for the user

Return type:

Dict

Returns:

Created user data

update(id, username=None, email=None, password=None, name=None, first_name=None, last_name=None, description=None, url=None, roles=None, **kwargs)[source]

Update an existing user

Parameters:
  • id (int) – User ID

  • username (str) – Username for the user

  • email (str) – Email address for the user

  • password (str) – Password for the user

  • name (str) – Display name for the user

  • first_name (str) – First name for the user

  • last_name (str) – Last name for the user

  • description (str) – Description/bio for the user

  • url (str) – URL/website for the user

  • roles (List[str]) – List of roles for the user

Return type:

Dict

Returns:

Updated user data

me(**params)[source]

Get the current user

Parameters:

**params – Query parameters

Return type:

Dict

Returns:

Current user data

Module contents

WordPress REST API Endpoints

Collection of endpoint classes for the WordPress REST API

class wp_api.endpoints.BaseEndpoint(client)[source]

Bases: object

Base class for WordPress REST API endpoints

__init__(client)[source]

Initialize the endpoint with a client instance

Parameters:

client – WordPress API client instance

create(data)[source]

Create a new item

Parameters:

data (Dict) – Item data

Return type:

Dict

Returns:

Created item data

delete(id, **params)[source]

Delete an item

Parameters:
  • id (int) – Item ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Deleted item data

endpoint = None
get(id, **params)[source]

Get a single item by ID

Parameters:
  • id (int) – Item ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Item data

list(**params)[source]

Get a list of items from this endpoint

Parameters:

**params – Query parameters to include in the request

Return type:

List[Dict]

Returns:

List of items

update(id, data)[source]

Update an existing item

Parameters:
  • id (int) – Item ID

  • data (Dict) – Item data to update

Return type:

Dict

Returns:

Updated item data

class wp_api.endpoints.Posts(client)[source]

Bases: BaseEndpoint

WordPress Posts API wrapper

create(title, content=None, excerpt=None, status='publish', author=None, featured_media=None, comment_status=None, ping_status=None, format=None, categories=None, tags=None, **kwargs)[source]

Create a new post

Parameters:
  • title (str) – Post title

  • content (str) – Post content

  • excerpt (str) – Post excerpt

  • status (str) – Post status (publish, future, draft, pending, private)

  • author (int) – Post author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • format (str) – Post format (standard, aside, chat, gallery, link, image, quote, status, video, audio)

  • categories (List[int]) – List of category IDs

  • tags (List[int]) – List of tag IDs

Return type:

Dict

Returns:

Created post data

endpoint = 'posts'
get_revision(post_id, revision_id, **params)[source]

Get a specific post revision

Parameters:
  • post_id (int) – Post ID

  • revision_id (int) – Revision ID

  • **params – Query parameters

Return type:

Dict

Returns:

Post revision data

get_revisions(post_id, **params)[source]

Get post revisions

Parameters:
  • post_id (int) – Post ID

  • **params – Query parameters

Return type:

List[Dict]

Returns:

List of post revisions

list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', slug=None, status='publish', categories=None, categories_exclude=None, tags=None, tags_exclude=None, sticky=None, tax_relation=None, **kwargs)[source]

List posts with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to posts published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to posts assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes posts assigned to specific authors

  • before (str) – Limit response to posts published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • slug (Union[str, List[str]]) – Limit result set to posts with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to posts with specific statuses

  • categories (Union[int, List[int]]) – Limit result set to items with specific categories

  • categories_exclude (Union[int, List[int]]) – Limit result set to items without specified categories

  • tags (Union[int, List[int]]) – Limit result set to items with specific tags

  • tags_exclude (Union[int, List[int]]) – Limit result set to items without specific tags

  • sticky (bool) – Limit result set to items that are sticky

  • tax_relation (str) – Taxonomy relationship (AND/OR)

Return type:

List[Dict]

Returns:

List of posts

update(id, title=None, content=None, excerpt=None, status=None, author=None, featured_media=None, comment_status=None, ping_status=None, format=None, categories=None, tags=None, **kwargs)[source]

Update an existing post

Parameters:
  • id (int) – Post ID

  • title (str) – Post title

  • content (str) – Post content

  • excerpt (str) – Post excerpt

  • status (str) – Post status (publish, future, draft, pending, private)

  • author (int) – Post author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • format (str) – Post format (standard, aside, chat, gallery, link, image, quote, status, video, audio)

  • categories (List[int]) – List of category IDs

  • tags (List[int]) – List of tag IDs

Return type:

Dict

Returns:

Updated post data

class wp_api.endpoints.Pages(client)[source]

Bases: BaseEndpoint

WordPress Pages API wrapper

create(title, content=None, excerpt=None, status='publish', author=None, featured_media=None, comment_status=None, ping_status=None, menu_order=None, parent=None, template=None, **kwargs)[source]

Create a new page

Parameters:
  • title (str) – Page title

  • content (str) – Page content

  • excerpt (str) – Page excerpt

  • status (str) – Page status (publish, future, draft, pending, private)

  • author (int) – Page author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • menu_order (int) – The order in which the page should appear in menus

  • parent (int) – Parent page ID

  • template (str) – Page template to use

Return type:

Dict

Returns:

Created page data

endpoint = 'pages'
get_revision(page_id, revision_id, **params)[source]

Get a specific page revision

Parameters:
  • page_id (int) – Page ID

  • revision_id (int) – Revision ID

  • **params – Query parameters

Return type:

Dict

Returns:

Page revision data

get_revisions(page_id, **params)[source]

Get page revisions

Parameters:
  • page_id (int) – Page ID

  • **params – Query parameters

Return type:

List[Dict]

Returns:

List of page revisions

list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, menu_order=None, offset=None, order='desc', orderby='date', parent=None, parent_exclude=None, slug=None, status='publish', **kwargs)[source]

List pages with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to pages published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to pages assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes pages assigned to specific authors

  • before (str) – Limit response to pages published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • menu_order (int) – Limit result set to pages with a specific menu_order value

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • parent (Union[int, List[int]]) – Limit result set to items with particular parent IDs

  • parent_exclude (Union[int, List[int]]) – Limit result set to all items except those with specific parent IDs

  • slug (Union[str, List[str]]) – Limit result set to pages with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to pages with specific statuses

Return type:

List[Dict]

Returns:

List of pages

update(id, title=None, content=None, excerpt=None, status=None, author=None, featured_media=None, comment_status=None, ping_status=None, menu_order=None, parent=None, template=None, **kwargs)[source]

Update an existing page

Parameters:
  • id (int) – Page ID

  • title (str) – Page title

  • content (str) – Page content

  • excerpt (str) – Page excerpt

  • status (str) – Page status (publish, future, draft, pending, private)

  • author (int) – Page author ID

  • featured_media (int) – Featured image ID

  • comment_status (str) – Whether comments are allowed (open, closed)

  • ping_status (str) – Whether pings are allowed (open, closed)

  • menu_order (int) – The order in which the page should appear in menus

  • parent (int) – Parent page ID

  • template (str) – Page template to use

Return type:

Dict

Returns:

Updated page data

class wp_api.endpoints.Users(client)[source]

Bases: BaseEndpoint

WordPress Users API wrapper

create(username, email, password, name=None, first_name=None, last_name=None, description=None, url=None, roles=None, **kwargs)[source]

Create a new user (requires proper authentication with user creation capabilities)

Parameters:
  • username (str) – Username for the user

  • email (str) – Email address for the user

  • password (str) – Password for the user

  • name (str) – Display name for the user

  • first_name (str) – First name for the user

  • last_name (str) – Last name for the user

  • description (str) – Description/bio for the user

  • url (str) – URL/website for the user

  • roles (List[str]) – List of roles for the user

Return type:

Dict

Returns:

Created user data

endpoint = 'users'
list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, offset=None, order='asc', orderby='name', slug=None, roles=None, **kwargs)[source]

List users with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, registered_date, etc.)

  • slug (Union[str, List[str]]) – Limit result set to users with one or more specific slugs

  • roles (Union[str, List[str]]) – Limit result set to users matching at least one specific role

Return type:

List[Dict]

Returns:

List of users

me(**params)[source]

Get the current user

Parameters:

**params – Query parameters

Return type:

Dict

Returns:

Current user data

update(id, username=None, email=None, password=None, name=None, first_name=None, last_name=None, description=None, url=None, roles=None, **kwargs)[source]

Update an existing user

Parameters:
  • id (int) – User ID

  • username (str) – Username for the user

  • email (str) – Email address for the user

  • password (str) – Password for the user

  • name (str) – Display name for the user

  • first_name (str) – First name for the user

  • last_name (str) – Last name for the user

  • description (str) – Description/bio for the user

  • url (str) – URL/website for the user

  • roles (List[str]) – List of roles for the user

Return type:

Dict

Returns:

Updated user data

class wp_api.endpoints.Media(client)[source]

Bases: BaseEndpoint

WordPress Media API wrapper

endpoint = 'media'
list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', parent=None, parent_exclude=None, slug=None, status='inherit', media_type=None, mime_type=None, **kwargs)[source]

List media items with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to media items published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to media items assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes media items assigned to specific authors

  • before (str) – Limit response to media items published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • parent (Union[int, List[int]]) – Limit result set to items with specific parent IDs

  • parent_exclude (Union[int, List[int]]) – Limit result set to all items except those with specific parent IDs

  • slug (Union[str, List[str]]) – Limit result set to media items with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to media items with specific statuses

  • media_type (str) – Limit result set to media items with a specific media type

  • mime_type (str) – Limit result set to media items with a specific MIME type

Return type:

List[Dict]

Returns:

List of media items

update(id, title=None, caption=None, description=None, alt_text=None, **kwargs)[source]

Update an existing media item

Parameters:
  • id (int) – Media item ID

  • title (str) – Title for the media item

  • caption (str) – Caption for the media item

  • description (str) – Description for the media item

  • alt_text (str) – Alternative text for the media item

Return type:

Dict

Returns:

Updated media item data

upload(file_data, file_name=None, title=None, caption=None, description=None, alt_text=None, **kwargs)[source]

Upload a new media file

Parameters:
  • file_data (BinaryIO) – File data (file-like object in binary mode)

  • file_name (str) – Name of the file

  • title (str) – Title for the media item

  • caption (str) – Caption for the media item

  • description (str) – Description for the media item

  • alt_text (str) – Alternative text for the media item

Return type:

Dict

Returns:

Created media item data

class wp_api.endpoints.Categories(client)[source]

Bases: BaseEndpoint

WordPress Categories API wrapper

create(name, slug=None, parent=None, description=None, **kwargs)[source]

Create a new category

Parameters:
  • name (str) – Name of the category

  • slug (str) – Slug for the category (optional)

  • parent (int) – Parent category ID (optional)

  • description (str) – Description of the category (optional)

Return type:

Dict

Returns:

Created category data

endpoint = 'categories'
list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, parent=None, post=None, slug=None, **kwargs)[source]

List categories with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, slug, etc.)

  • hide_empty (bool) – Whether to hide categories that don’t have any posts

  • parent (int) – Limit result set to categories that have a specific parent ID

  • post (int) – Limit result set to categories assigned to a specific post

  • slug (Union[str, List[str]]) – Limit result set to categories with one or more specific slugs

Return type:

List[Dict]

Returns:

List of categories

update(id, name=None, slug=None, parent=None, description=None, **kwargs)[source]

Update an existing category

Parameters:
  • id (int) – Category ID

  • name (str) – Name of the category (optional)

  • slug (str) – Slug for the category (optional)

  • parent (int) – Parent category ID (optional)

  • description (str) – Description of the category (optional)

Return type:

Dict

Returns:

Updated category data

class wp_api.endpoints.Tags(client)[source]

Bases: BaseEndpoint

WordPress Tags API wrapper

create(name, slug=None, description=None, **kwargs)[source]

Create a new tag

Parameters:
  • name (str) – Name of the tag

  • slug (str) – Slug for the tag (optional)

  • description (str) – Description of the tag (optional)

Return type:

Dict

Returns:

Created tag data

endpoint = 'tags'
list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, post=None, slug=None, **kwargs)[source]

List tags with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, slug, etc.)

  • hide_empty (bool) – Whether to hide tags that don’t have any posts

  • post (int) – Limit result set to tags assigned to a specific post

  • slug (Union[str, List[str]]) – Limit result set to tags with one or more specific slugs

Return type:

List[Dict]

Returns:

List of tags

update(id, name=None, slug=None, description=None, **kwargs)[source]

Update an existing tag

Parameters:
  • id (int) – Tag ID

  • name (str) – Name of the tag (optional)

  • slug (str) – Slug for the tag (optional)

  • description (str) – Description of the tag (optional)

Return type:

Dict

Returns:

Updated tag data

class wp_api.endpoints.Comments(client)[source]

Bases: BaseEndpoint

WordPress Comments API wrapper

create(post, content, author=None, author_name=None, author_email=None, author_url=None, parent=None, status=None, **kwargs)[source]

Create a new comment

Parameters:
  • post (int) – Post ID to which the comment belongs

  • content (str) – Content of the comment

  • author (int) – User ID of the comment author (if registered)

  • author_name (str) – Name of the comment author (if not registered)

  • author_email (str) – Email of the comment author (if not registered)

  • author_url (str) – URL/website of the comment author (if not registered)

  • parent (int) – Parent comment ID (for threaded comments)

  • status (str) – Comment status (approve, hold, spam, trash)

Return type:

Dict

Returns:

Created comment data

endpoint = 'comments'
list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, author_email=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date_gmt', parent=None, parent_exclude=None, post=None, status='approve', type='comment', password=None, **kwargs)[source]

List comments with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to comments published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to comments assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes comments assigned to specific authors

  • author_email (str) – Limit result set to comments with a specific author email

  • before (str) – Limit response to comments published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, id, include, post, parent, type)

  • parent (Union[int, List[int]]) – Limit result set to comments with specific parent IDs

  • parent_exclude (Union[int, List[int]]) – Limit result set to all items except those with specific parent IDs

  • post (Union[int, List[int]]) – Limit result set to comments assigned to specific posts

  • status (str) – Limit result set to comments with a specific status (approve, hold, spam, trash)

  • type (str) – Limit result set to comments with a specific type (comment, pingback, trackback)

  • password (str) – Filter comments by post password, if the post is password protected

Return type:

List[Dict]

Returns:

List of comments

update(id, content=None, author=None, author_name=None, author_email=None, author_url=None, post=None, parent=None, status=None, **kwargs)[source]

Update an existing comment

Parameters:
  • id (int) – Comment ID

  • content (str) – Content of the comment

  • author (int) – User ID of the comment author (if registered)

  • author_name (str) – Name of the comment author (if not registered)

  • author_email (str) – Email of the comment author (if not registered)

  • author_url (str) – URL/website of the comment author (if not registered)

  • post (int) – Post ID to which the comment belongs

  • parent (int) – Parent comment ID (for threaded comments)

  • status (str) – Comment status (approve, hold, spam, trash)

Return type:

Dict

Returns:

Updated comment data

class wp_api.endpoints.Settings(client)[source]

Bases: BaseEndpoint

WordPress Settings API wrapper

endpoint = 'settings'
get(**params)[source]

Get all settings

Parameters:

**params – Query parameters to include in the request

Return type:

Dict[str, Any]

Returns:

Dictionary of settings

update(**settings)[source]

Update settings

Parameters:

**settings – Settings to update as keyword arguments

Return type:

Dict[str, Any]

Returns:

Updated settings

class wp_api.endpoints.Taxonomies(client)[source]

Bases: BaseEndpoint

WordPress Taxonomies API wrapper

endpoint = 'taxonomies'
get(taxonomy, **params)[source]

Get a specific taxonomy

Parameters:
  • taxonomy (str) – Taxonomy slug (e.g., ‘category’, ‘post_tag’)

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Taxonomy data

list(**params)[source]

Get all registered taxonomies

Parameters:

**params – Query parameters to include in the request

Return type:

Dict[str, Dict]

Returns:

Dictionary of taxonomies

class wp_api.endpoints.Terms(client, taxonomy)[source]

Bases: BaseEndpoint

Base class for taxonomy terms endpoints

Parameters:

taxonomy (str)

__init__(client, taxonomy)[source]

Initialize the terms endpoint with a client instance and taxonomy

Parameters:
  • client – WordPress API client instance

  • taxonomy (str) – Taxonomy slug (e.g., ‘category’, ‘post_tag’)

create(name, slug=None, description=None, parent=None, meta=None, **kwargs)[source]

Create a new term

Parameters:
  • name (str) – Term name

  • slug (str) – Term slug

  • description (str) – Term description

  • parent (int) – Parent term ID

  • meta (Dict) – Term meta data

Return type:

Dict

Returns:

Created term data

delete(id, force=False)[source]

Delete a term

Parameters:
  • id (int) – Term ID

  • force (bool) – Whether to bypass the trash and force deletion

Return type:

Dict

Returns:

Deleted term data

get(id, **params)[source]

Get a specific term

Parameters:
  • id (int) – Term ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Term data

list(context='view', page=1, per_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, parent=None, post=None, slug=None, **kwargs)[source]

List taxonomy terms with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (id, name, slug, etc.)

  • hide_empty (bool) – Whether to hide terms that don’t have any posts

  • parent (int) – Limit result set to terms that have a specific parent ID

  • post (int) – Limit result set to terms assigned to a specific post

  • slug (Union[str, List[str]]) – Limit result set to terms with one or more specific slugs

Return type:

List[Dict]

Returns:

List of terms

update(id, name=None, slug=None, description=None, parent=None, meta=None, **kwargs)[source]

Update an existing term

Parameters:
  • id (int) – Term ID

  • name (str) – Term name

  • slug (str) – Term slug

  • description (str) – Term description

  • parent (int) – Parent term ID

  • meta (Dict) – Term meta data

Return type:

Dict

Returns:

Updated term data

class wp_api.endpoints.CustomFields(client, post_type='posts')[source]

Bases: BaseEndpoint

WordPress Custom Fields (post meta) API wrapper

Parameters:

post_type (str)

__init__(client, post_type='posts')[source]

Initialize the custom fields endpoint with a client instance and post type

Parameters:
  • client – WordPress API client instance

  • post_type (str) – Post type (posts, pages, or custom post type)

create(post_id, meta_key, meta_value)[source]

Create a new custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_key (str) – Meta key

  • meta_value (Any) – Meta value

Return type:

Dict

Returns:

Created meta data

delete(post_id, meta_id, force=True)[source]

Delete a custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_id (int) – Meta ID

  • force (bool) – Whether to bypass the trash and force deletion

Return type:

Dict

Returns:

Deleted meta data

get(post_id, meta_key, **params)[source]

Get a specific custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_key (str) – Meta key

  • **params – Query parameters to include in the request

Return type:

Any

Returns:

Meta value

get_all(post_id, **params)[source]

Get all custom fields (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Post meta data

update(post_id, meta_id, meta_value)[source]

Update an existing custom field (meta) for a post

Parameters:
  • post_id (int) – Post ID

  • meta_id (int) – Meta ID

  • meta_value (Any) – New meta value

Return type:

Dict

Returns:

Updated meta data

update_or_create(post_id, meta_key, meta_value)[source]

Update an existing custom field or create if it doesn’t exist

Parameters:
  • post_id (int) – Post ID

  • meta_key (str) – Meta key

  • meta_value (Any) – Meta value

Return type:

Dict

Returns:

Updated or created meta data

class wp_api.endpoints.CustomPostType(client, post_type)[source]

Bases: BaseEndpoint

WordPress Custom Post Type API wrapper

Parameters:

post_type (str)

__init__(client, post_type)[source]

Initialize the custom post type endpoint with a client instance

Parameters:
  • client – WordPress API client instance

  • post_type (str) – Custom post type slug (e.g., ‘product’, ‘portfolio’, etc.)

create(title, content=None, status='publish', **kwargs)[source]

Create a new custom post type item

Parameters:
  • title (str) – Item title

  • content (str) – Item content

  • status (str) – Item status (publish, future, draft, pending, private)

  • **kwargs – Additional item data

Return type:

Dict

Returns:

Created custom post type item data

delete(id, force=False)[source]

Delete a custom post type item

Parameters:
  • id (int) – Item ID

  • force (bool) – Whether to bypass the trash and force deletion

Return type:

Dict

Returns:

Deleted custom post type item data

get(id, **params)[source]

Get a single custom post type item by ID

Parameters:
  • id (int) – Item ID

  • **params – Query parameters to include in the request

Return type:

Dict

Returns:

Custom post type item data

get_meta()[source]

Get a custom fields handler for this custom post type

Returns:

CustomFields endpoint handler for this custom post type

list(context='view', page=1, per_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', slug=None, status='publish', **kwargs)[source]

List custom post type items with various filtering options

Parameters:
  • context (str) – Scope under which the request is made (view, edit, embed)

  • page (int) – Current page of the collection

  • per_page (int) – Maximum number of items to be returned in result set

  • search (str) – Limit results to those matching a string

  • after (str) – Limit response to posts published after a given ISO8601 compliant date

  • author (Union[int, List[int]]) – Limit result set to posts assigned to specific authors

  • author_exclude (Union[int, List[int]]) – Ensure result set excludes posts assigned to specific authors

  • before (str) – Limit response to posts published before a given ISO8601 compliant date

  • exclude (Union[int, List[int]]) – Ensure result set excludes specific IDs

  • include (Union[int, List[int]]) – Limit result set to specific IDs

  • offset (int) – Offset the result set by a specific number of items

  • order (str) – Order sort attribute ascending or descending (asc, desc)

  • orderby (str) – Sort collection by object attribute (date, author, title, etc.)

  • slug (Union[str, List[str]]) – Limit result set to posts with one or more specific slugs

  • status (Union[str, List[str]]) – Limit result set to posts with specific statuses

Return type:

List[Dict]

Returns:

List of custom post type items

update(id, title=None, content=None, status=None, **kwargs)[source]

Update an existing custom post type item

Parameters:
  • id (int) – Item ID

  • title (str) – Item title

  • content (str) – Item content

  • status (str) – Item status (publish, future, draft, pending, private)

  • **kwargs – Additional item data to update

Return type:

Dict

Returns:

Updated custom post type item data

class wp_api.endpoints.BlockPatterns(client)[source]

Bases: BaseEndpoint

WordPress Block Patterns API wrapper

__init__(client)[source]

Initialize the block patterns endpoint with a client instance

Parameters:

client – WordPress API client instance

get_categories(**params)[source]

Get all registered block pattern categories

Parameters:

**params – Query parameters to include in the request

Return type:

List[Dict]

Returns:

List of block pattern categories

list(**params)[source]

Get all registered block patterns

Parameters:

**params – Query parameters to include in the request

Return type:

List[Dict]

Returns:

List of block patterns