Skip to main content

CommunityNotesClient

The CommunityNotesClient provides methods for creating, managing, and searching Community Notes on X.

create

Creates a community note.
from xdk.community_notes.models import CreateRequest

response = client.community_notes.create(
    body=CreateRequest(
        tweet_id="1234567890",
        text="This post may contain misleading information.",
        helpful=True
    )
)
body
CreateRequest
Request body containing the community note details.
CreateResponse
object
Response containing the created community note.

search_written

Returns all the community notes written by the user.
for page in client.community_notes.search_written(
    test_mode=False,
    max_results=50,
    note_fields=["id", "text", "created_at", "helpful_count"]
):
    for note in page.data:
        print(f"Note: {note.text}")
test_mode
bool
required
If true, return the notes the caller wrote for the test. If false, return the notes the caller wrote on the product.
pagination_token
str
Pagination token to get next set of posts eligible for notes.
max_results
int
Max results to return.
note_fields
List[str]
A comma separated list of Note fields to display.
SearchWrittenResponse
Iterator
Iterator that yields pages of community notes. Automatically handles pagination.

search_eligible_posts

Returns all the posts that are eligible for community notes.
for page in client.community_notes.search_eligible_posts(
    test_mode=False,
    max_results=20,
    post_selection="feed_size: small, feed_lang: en"
):
    for post in page.data:
        print(f"Eligible post: {post.id}")
test_mode
bool
required
If true, return a list of posts that are for the test. If false, return a list of posts that the bots can write proposed notes on the product.
pagination_token
str
Pagination token to get next set of posts eligible for notes.
max_results
int
Max results to return.
post_selection
str
The selection of posts to return. Valid values are ‘feed_size: [small|large|xl], feed_lang: [en|es|…|all]’. Default is ‘feed_size: small, feed_lang: en’.
SearchEligiblePostsResponse
Iterator
Iterator that yields pages of posts eligible for community notes. Automatically handles pagination.

delete

Deletes a community note.
response = client.community_notes.delete(
    id="1234567890"
)
id
str
required
The community note id to delete.
DeleteResponse
object
Response confirming the community note was deleted.

Build docs developers (and LLMs) love