# Automating a WordPress Chess Workflow: Notes on the Python Tools

- Link: https://coffeefordessert.com/2026/11/02/automating-a-wordpress-chess-workflow-notes-on-the-python-tools/
- Published: 2026-11-02T14:00:00-06:00
- Author: Chad Ambrose

Automating a WordPress Chess Content Workflow

Stage

Python Tools/Libraries

1. Scrape PGNs (Chess.com)

requests, Chess.com PubAPI endpoints

1. Scrape PGNs (Lichess)

requests, Lichess API endpoints

2. WordPress Draft Posts

requests or wp-api-python for REST API

3. Create GIFs from PGN

chess_gif (pip), python-chess, imageio

4. Generate Images

python-chess (SVG rendering), cairosvg, Pillow

5. Social Posting

tweepy (Twitter), instabot (Instagram), scheduling (cron or schedule)

1. Scraping PGN Games

Chess.com: Use the Chess.com Published Data API to fetch games. For example, hit
[https://api.chess.com/pub/player/](https://api.chess.com/pub/player/){username}/
games/archives to list a user’s archives, then fetch each archive’s PGN via /games/{
YYYY}/{MM}/pgn. In Python, you can use requests.get(…) with a custom User-Agent 
header. For instance:

import requests username = “erik” url = f”[https://api.chess.com/pub/player/](https://api.chess.com/pub/player/){
username}/games/archives” res = requests.get(url, headers={“User-Agent”: “my-script”})
archives = res.json()[“archives”] for archive in archives: pgn = requests.get(f”{
archive}/pgn”, headers={“User-Agent”: “my-script”}) with open(“chess_com_games.pgn”,“
a”) as f: f.write(pgn.text + “\n”)

This approach follows Chess.com’s own examples of using the archives endpoint. Lichess:
Lichess’s API lets you export all games of a user in PGN format. For example, you
can stream the games with a call like [https://lichess.org/api/games/user/](https://lichess.org/api/games/user/){
username} and set the Accept header to “application/x-ndjson” for raw PGN (or “application/
x-chess-pgn”). Example Python snippet:

username = “lichess_user” url = f”[https://lichess.org/api/games/user/](https://lichess.org/api/games/user/){
username}” res = requests.get(url, headers={“Accept”: “application/x-chess-pgn”})
with open(“lichess_games.pgn”, “w”) as f: f.write(res.text)

The Lichess API supports filters (by date, opponent, etc.) and returns games in 
reverse-chronological order.

2. Creating/Updating WordPress Draft Posts

WordPress REST API: Use the WP REST API v2 (/wp-json/wp/v2/posts) to create or update
posts. You can send a POST (for new) or PUT (to update) with JSON data. For example:

import requests wp_url = “[https://yourblog.com/wp-json/wp/v2/posts&#8221](https://yourblog.com/wp-json/wp/v2/posts&#8221);
data = { “title”: “My Chess Game Review”, “content”: “Example content with PGN link
or summary.”, “status”: “draft”, “tags”: [“blitz”, “endgame”] # use tag IDs or slugs
as needed } res = requests.post(wp_url, json=data, auth=(‘wp_user’,’wp_password’))
print(res.status_code, res.json())

This uses HTTP Basic Auth (or JWT/OAuth) as required. Alternatively, the wp-api-
python library (pip install wp-api-python) provides a wrapper; e.g.:

from wordpress_api import WordPressAPI wp = WordPressAPI(url=’[https://yourblog.com&#8217](https://yourblog.com&#8217);,
username=’user’, password=’pass’) wp.posts.create({ ‘title’: ‘Game vs Kasparov’,‘
content’: ‘PGN: …’, ‘status’: ‘draft’, ‘tags’: [‘tactic’,’legendary’] })

In both cases you can include tags, categories, etc. with their IDs or names. The
wp-api-python library is designed to simplify REST interactions .

3. Generating Chess Game GIFs

Using chess_gif: Install the chess_gif package (pip install chess_gif) which wraps
python-chess and image libraries to create GIFs. For example:

from chess_gif.gif_maker import GIFMaker maker = GIFMaker(delay=1000, h_margin=20,
v_margin=80) maker.make_gif_from_pgn_file(‘games.pgn’, ‘output.gif’)

This reads a PGN file and outputs an animated GIF of the game moves. Alternative
approaches: You can also manually parse the PGN (e.g. with python-chess) and generate
frames. For each move, render the board to an image (e.g. using python-chess’s SVG
board or matplotlib) and then use imageio or ffmpeg to stitch frames. For example,
using python-chess and imageio:

import chess, chess.svg, imageio board = chess.Board() writer = imageio.get_writer(‘
game.gif’, mode=’I’, duration=0.5) for move in board.variation_san(list(board.move_stack)):
board.push_san(move) # play moves from PGN svg = chess.svg.board(board=board, lastmove
=board.peek()) png = svg2png(bytestring=svg) # requires cairosvg writer.append_data(
imageio.imread(png)) writer.close()

The chess_gif library automates this (using python-chess, Pillow, imageio under 
the hood).

4. Generating Social Media Images

Chessboard rendering: Use python-chess’s SVG rendering to get a board image. For
a key position, you can load or set the Board state and call chess.svg.board(). 
Example:

import chess, chess.svg from cairosvg import svg2png board = chess.Board(“r1bqkbnr/
pppppppp/n7/8/8/8/PPPPPPPP/RNBQKBNR w KQkq – 2 2”) svg_data = chess.svg.board(board
=board, size=400) svg2png(bytestring=svg_data, write_to=’position.png’)

This produces position.png showing the board (requires the cairosvg package to convert
SVG→PNG). The python-chess chess.svg.board() function is specifically for rendering
boards as SVG. Annotations & styling: Once you have a base board image (PNG), use
imaging libraries to add emojis, text, frames, etc. For example, use Pillow to overlay
text/captions or border images:

from PIL import Image, ImageDraw, ImageFont img = Image.open(“position.png”) draw
= ImageDraw.Draw(img) font = ImageFont.truetype(“arial.ttf”, 24) draw.text((10, 
410), “White to move!”, (255,255,255), font=font) img.save(“social_post.png”)

Alternatively, matplotlib or other plotting libraries can place images and text.
The combination of python-chess rendering + Pillow or matplotlib lets you create
polished images. (Libraries like Canva also provide APIs, but pure-Python solutions
give more control.)

5. Scheduling/Posting to Twitter and Instagram

Twitter (Tweepy): Use the Tweepy library (pip install tweepy) to interact with Twitter’s
API. Authenticate via OAuth (API keys/tokens) and then post. Example (Twitter API
v2):

import tweepy client = tweepy.Client( bearer_token=’BEARER_TOKEN’, consumer_key=’
API_KEY’, consumer_secret=’API_SECRET’, access_token=’ACCESS_TOKEN’, access_token_secret
=’ACCESS_SECRET’ ) response = client.create_tweet(text=”My latest chess blog post
is live!”) print(“Tweeted:”, response.data[‘id’])

This requires Twitter developer keys. The example shows creating a tweet via client.
create_tweet(…).  The Tweepy library is the standard Python wrapper for Twitter.
Instagram (Instabot): Instagram’s API is more restrictive, but third-party libraries
like Instabot (pip install instabot) can automate posting. For example:

from instabot import Bot bot = Bot() bot.login(username=”insta_user”, password=”
insta_pass”) bot.upload_photo(“social_post.png”, caption=”My new chess puzzle! ♟️”)
bot.logout()

This script logs in and uploads an image with a caption. (In practice, you may need
to resize to Instagram’s 1080×1080 requirement and handle 2FA.) The Instabot library
simplifies these steps. Scheduling: Run your Python scripts on a schedule. You can
use system tools (e.g. cron on Linux/macOS, Task Scheduler on Windows) to run a 
script at fixed times, or Python packages like schedule ([https://pypi.org/project/schedule](https://pypi.org/project/schedule))
to programmatically trigger posts. For example, a cron entry:

0 9 * * * /usr/bin/python3 /path/to/chess_post_script.py

would run it every day at 9am. (One tutorial suggests scheduling tweets with cron
and Tweepy.) Using these methods, you can fully automate posting new chess game 
content to WordPress, Twitter, and Instagram.

Each of these steps can be scripted and combined into a single workflow. For example,
after scraping and processing new games, your script could automatically create 
draft blog posts (with tags), generate the GIF/image assets, and then either schedule
or immediately publish to social media. The Python tools mentioned above provide
a solid starting point for each component of the process.

Sources: Chess.com and Lichess published APIs; python-wordpress-API library ; chess_gif
documentation; python-chess SVG rendering; Tweepy and Instabot documentation/examples.
