{
    "type": "project",
    "title": "Apple News API",
    "canonical": "https://www.dealmobile.co.uk/projects/apple-news-api",
    "path": "/projects/apple-news-api",
    "url": "https://www.dealmobile.co.uk/projects/apple-news-api",
    "markdown": "https://www.dealmobile.co.uk/projects/apple-news-api.md",
    "json": "https://www.dealmobile.co.uk/projects/apple-news-api.json",
    "summary": "A PHP 8.1 library for the Apple News Publisher API. It signs requests, builds Apple News Format documents in PHP objects and handles articles, sections and channels.",
    "published": "2026-10-20T10:43:31+01:00",
    "modified": "2026-10-25T18:32:07+00:00",
    "image": {
        "url": "https://www.dealmobile.co.uk/sites/default/files/content/images/products/apple-news-api-light.png",
        "alt": "The documentation home page for the Apple News API PHP client, listing its namespaces and packages."
    },
    "fields": {
        "featured": false,
        "kind": "library",
        "licence": "MIT",
        "links": [
            {
                "title": "Documentation",
                "url": "https://applenews.dealmobile.co.uk"
            },
            {
                "title": "Source on GitHub",
                "url": "https://github.com/tomgould/Apple-News-API"
            },
            {
                "title": "Package on Packagist",
                "url": "https://packagist.org/packages/tomgould/apple-news-api"
            }
        ],
        "stack": [
            "PHP",
            "Composer",
            "PSR HTTP standards",
            "HMAC request signing",
            "PHPUnit",
            "PHPStan",
            "GitHub Actions",
            "Apple News",
            "Apple News Format"
        ],
        "started": 2025,
        "status": "maintained",
        "tagline": "A PHP client for publishing articles to Apple News, with a document builder for the whole Apple News Format."
    },
    "body": {
        "html": "<p>Apple News API is a PHP library for publishers who want to send their articles to Apple News. It talks to the Apple News Publisher API and builds the Apple News Format (ANF) documents that Apple expects, so a CMS or a script can publish, update and delete articles without hand-writing JSON.</p>\n<h2 id=\"what-it-does\">What it does</h2>\n<ul>\n<li>Signs every request with Apple’s HMAC-SHA256 scheme, from your API key ID and secret.</li>\n<li>Builds ANF documents with PHP objects: more than 45 component types, from titles, body text and photos to galleries, video, maps, tables, social embeds and adverts.</li>\n<li>Covers the rest of the format too: component and text styles, layouts, animations, scroll behaviours, header scenes, fills, and conditional styles for dark mode, screen width or platform.</li>\n<li>Supports Live Coverage articles, with live posts and a coverage state you can update until the story ends.</li>\n<li>Publishes articles with their images as a multipart request, and reads, searches, updates, promotes and deletes them. It also reads channels, sections and quotas.</li>\n<li>Turns Apple’s error responses into exceptions that carry Apple’s error code and the key path of the field that failed, for example <code>components[0].text</code>.</li>\n</ul>\n<h2 id=\"how-its-built\">How it’s built</h2>\n<p>The library needs PHP 8.1 or later and uses strict types and named arguments throughout. It has no framework dependency. For HTTP it uses the PSR-18 client and PSR-17 factory interfaces, so it works with Guzzle, Symfony’s HTTP client or any other compatible client you already use.</p>\n<p>Requests are signed by a small authenticator class. It builds a canonical string from the method, URL and date, adds the content type and body for POST requests, and signs it with the base64-decoded secret. Article uploads are built by a multipart builder that adds the <code>article.json</code> part, the optional metadata part and one part per image in the article’s bundle.</p>\n<p>The document builder handles some details of the format that are easy to get wrong. For example, PHP’s <code>json_encode</code> turns an empty array into <code>[]</code>, but Apple wants <code>{}</code> for an empty layout or style, so the article converts empty arrays to objects before it’s serialised. Live Coverage containers refuse anything but live posts, and live posts refuse to be nested, with a clear exception rather than an error from Apple later.</p>\n<p>PHPUnit covers the library, PHPStan checks it at level 8, and GitHub Actions runs both. The API reference is generated from the docblocks with phpDocumentor and published at <a href=\"https://applenews.dealmobile.co.uk\">applenews.dealmobile.co.uk</a>. Releases follow semantic versioning, with a changelog for each one.</p>\n<h2 id=\"how-to-use-it\">How to use it</h2>\n<p>Install it with Composer, along with a PSR-18 client such as Guzzle:</p>\n<pre><code class=\"language-bash\">composer require tomgould/apple-news-api guzzlehttp/guzzle guzzlehttp/psr7\n</code></pre>\n<p>Then create a client, build an article and publish it:</p>\n<pre><code class=\"language-php\">use TomGould\\AppleNews\\Client\\AppleNewsClient;\nuse TomGould\\AppleNews\\Document\\Article;\nuse TomGould\\AppleNews\\Document\\Components\\{Title, Body};\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Psr7\\HttpFactory;\n\n$factory = new HttpFactory();\n$client = AppleNewsClient::create(\n    keyId: 'your-api-key-id',\n    keySecret: 'your-api-secret',\n    httpClient: new Client(),\n    requestFactory: $factory,\n    streamFactory: $factory\n);\n\n$article = Article::create(identifier: 'story-123', title: 'A headline', language: 'en')\n    -&gt;addComponent(new Title('A headline'))\n    -&gt;addComponent(new Body('The first paragraph.'));\n\n$response = $client-&gt;createArticle('your-channel-id', $article);\n</code></pre>\n<p>You need your own Apple News Publisher channel and API credentials. The <a href=\"https://github.com/tomgould/Apple-News-API\">README</a> has a full guide to every component, style and API call.</p>"
    },
    "markdown_text": "---\ntitle: 'Apple News API'\ncanonical: 'https://www.dealmobile.co.uk/projects/apple-news-api'\nurl: 'https://www.dealmobile.co.uk/projects/apple-news-api'\ntype: Project\nsummary: 'A PHP 8.1 library for the Apple News Publisher API. It signs requests, builds Apple News Format documents in PHP objects and handles articles, sections and channels.'\n---\n\n# Apple News API\n\nA PHP client for publishing articles to Apple News, with a document builder for the whole Apple News Format.\n\n![The documentation home page for the Apple News API PHP client, listing its namespaces and packages.](https://www.dealmobile.co.uk/sites/default/files/styles/almanac_shot_md/public/content/images/products/apple-news-api-light.png.webp?itok=iMY9BW4Z)\n\n- **Kind:** Library\n- **Status:** Maintained\n- **Started:** 2025\n- **Licence:** MIT\n- **Stack:** PHP, Composer, PSR HTTP standards, HMAC request signing, PHPUnit, PHPStan, GitHub Actions, Apple News, Apple News Format\n- **Links:** [Documentation](https://applenews.dealmobile.co.uk), [Source on GitHub](https://github.com/tomgould/Apple-News-API), [Package on Packagist](https://packagist.org/packages/tomgould/apple-news-api)\n\nApple News API is a PHP library for publishers who want to send their articles to Apple News. It talks to the Apple News Publisher API and builds the Apple News Format (ANF) documents that Apple expects, so a CMS or a script can publish, update and delete articles without hand-writing JSON.\n\n## What it does\n\n- Signs every request with Apple’s HMAC-SHA256 scheme, from your API key ID and secret.\n- Builds ANF documents with PHP objects: more than 45 component types, from titles, body text and photos to galleries, video, maps, tables, social embeds and adverts.\n- Covers the rest of the format too: component and text styles, layouts, animations, scroll behaviours, header scenes, fills, and conditional styles for dark mode, screen width or platform.\n- Supports Live Coverage articles, with live posts and a coverage state you can update until the story ends.\n- Publishes articles with their images as a multipart request, and reads, searches, updates, promotes and deletes them. It also reads channels, sections and quotas.\n- Turns Apple’s error responses into exceptions that carry Apple’s error code and the key path of the field that failed, for example `components[0].text`.\n\n## How it’s built\n\nThe library needs PHP 8.1 or later and uses strict types and named arguments throughout. It has no framework dependency. For HTTP it uses the PSR-18 client and PSR-17 factory interfaces, so it works with Guzzle, Symfony’s HTTP client or any other compatible client you already use.\n\nRequests are signed by a small authenticator class. It builds a canonical string from the method, URL and date, adds the content type and body for POST requests, and signs it with the base64-decoded secret. Article uploads are built by a multipart builder that adds the `article.json` part, the optional metadata part and one part per image in the article’s bundle.\n\nThe document builder handles some details of the format that are easy to get wrong. For example, PHP’s `json_encode` turns an empty array into `[]`, but Apple wants `{}` for an empty layout or style, so the article converts empty arrays to objects before it’s serialised. Live Coverage containers refuse anything but live posts, and live posts refuse to be nested, with a clear exception rather than an error from Apple later.\n\nPHPUnit covers the library, PHPStan checks it at level 8, and GitHub Actions runs both. The API reference is generated from the docblocks with phpDocumentor and published at [applenews.dealmobile.co.uk](https://applenews.dealmobile.co.uk). Releases follow semantic versioning, with a changelog for each one.\n\n## How to use it\n\nInstall it with Composer, along with a PSR-18 client such as Guzzle:\n\n```bash\ncomposer require tomgould/apple-news-api guzzlehttp/guzzle guzzlehttp/psr7\n\n```\n\nThen create a client, build an article and publish it:\n\n```php\nuse TomGould\\AppleNews\\Client\\AppleNewsClient;\nuse TomGould\\AppleNews\\Document\\Article;\nuse TomGould\\AppleNews\\Document\\Components\\{Title, Body};\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Psr7\\HttpFactory;\n\n$factory = new HttpFactory();\n$client = AppleNewsClient::create(\n    keyId: 'your-api-key-id',\n    keySecret: 'your-api-secret',\n    httpClient: new Client(),\n    requestFactory: $factory,\n    streamFactory: $factory\n);\n\n$article = Article::create(identifier: 'story-123', title: 'A headline', language: 'en')\n    ->addComponent(new Title('A headline'))\n    ->addComponent(new Body('The first paragraph.'));\n\n$response = $client->createArticle('your-channel-id', $article);\n\n```\n\nYou need your own Apple News Publisher channel and API credentials. The [README](https://github.com/tomgould/Apple-News-API) has a full guide to every component, style and API call.\n\n---\n\nIndex of this site: [llms.txt](https://www.dealmobile.co.uk/llms.txt)\n"
}