Export Managed Reddit Post and Comment Orders to CSV

Export the managed orders your authorized account can read. Verify the actual response and pagination with a small request before collecting the full set and writing a CSV.

Inspect one response

Use an account key permitted to read orders and keep it in an environment variable or secrets store. Read the List orders documentation, make one request, and record the collection, pagination and delivery URL fields you actually get.

Collect pages and reconcile IDs

Request the next page using the response metadata. Keep one record per order ID, stop at the documented final page, and log failures rather than silently returning a partial export. If orders may change while paginating, compare against a second run or use an agreed cutoff.

Create and inspect the CSV

Write a fixed set of columns with a CSV library rather than string concatenation. Leave missing delivery links blank. Neutralize formula-like text fields for spreadsheet use and test a row with a comma, a line break and a quoted title.

Python example

Set GOGLOBAL_ORDER_READ_KEY in your environment. Run the script with Python 3 to write reddit-orders.csv after every page has been read.

import csv
import json
import os
from urllib.parse import urlencode
from urllib.request import Request, urlopen

fields = ["id", "type", "status", "targetSubreddit", "createdAt", "redditUrl"]
token = os.environ["GOGLOBAL_ORDER_READ_KEY"]
orders = {}
page = 1

while True:
    query = urlencode({"page": page, "pageSize": 100})
    request = Request(f"https://www.goglobal.to/api/v1/orders?{query}")
    request.add_unredirected_header("Authorization", f"Bearer {token}")
    with urlopen(request, timeout=30) as response:
        result = json.load(response)
    if not result.get("success") or not isinstance(result.get("data"), dict):
        raise ValueError("Unexpected List orders response. Check the current API reference.")
    data = result["data"]
    pagination = data["pagination"]
    if pagination["page"] != page:
        raise ValueError("The order list changed during pagination. Start the export again.")
    for order in data["items"]:
        if order["type"] in {"post", "comment"}:
            orders[order["id"]] = order
    if not pagination["hasNextPage"]:
        break
    page += 1


def spreadsheet_cell(value):
    if value is None:
        return ""
    if isinstance(value, str) and value.lstrip().startswith(("=", "+", "-", "@")):
        return "'" + value
    return value


with open("reddit-orders.csv", "w", encoding="utf-8", newline="") as file:
    writer = csv.DictWriter(file, fieldnames=fields)
    writer.writeheader()
    for order in orders.values():
        writer.writerow({field: spreadsheet_cell(order.get(field)) for field in fields})

Worked example

An export for three orders has a permalink for the completed order, a blank link for the queued order, and a status field for the rejected order. All three IDs still appear in the CSV.

Confirm pricing, pagination, fields, permissions and rate limits against an authorized production response. Order status and public Reddit visibility need separate checks.

Sources and references