PHPackages                             spatie/twitter-oembed - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. spatie/twitter-oembed

ActiveLibrary[API Development](/categories/api)

spatie/twitter-oembed
=====================

Retrieve tweets with the Twitter oEmbed API

10913↓50%PHPCI passing

Since Jan 31Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/spatie/twitter-oembed)[ Packagist](https://packagist.org/packages/spatie/twitter-oembed)[ RSS](/packages/spatie-twitter-oembed/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Retrieve tweets with the Twitter oEmbed API
===========================================

[](#retrieve-tweets-with-the-twitter-oembed-api)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e737d8771cf928a36da212bbf48a3d6d41b01eb731d568cb65d3bca7f315a685/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f747769747465722d6f656d6265642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/twitter-oembed)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d61818e231d7411719a804c68e8146944276d18a93c1d84cdf5090a3d1e22432/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f747769747465722d6f656d6265642f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/spatie/twitter-oembed/actions?query=workflow%3ATests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/db4ceb3b86c9528ce7b43b55be47d5efc20eb6206ea012579557c91b7b684341/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f747769747465722d6f656d6265642f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/spatie/twitter-oembed/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/8ce78556eea3b7a12718a4bfc02d2edee594b16cb380d5f5f00d571f35cbd1e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f747769747465722d6f656d6265642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/twitter-oembed)

A utility package to retrieve tweets with Twitter's [oEmbed API](https://developer.twitter.com/en/docs/twitter-for-websites/oembed-api). The main benefit of Twitter's oEmbed API is that it's public. You don't need to set up a developer account to get started, but the data in the response is minimal.

This package is meant to set the stage for tools that embed Tweets. For example, a markdown plugin that embeds tweets as static HTML so your blog doesn't need a bloated JavaScript widget. Or a rich text editor plugin for your email platform so tweets can be embedded in newsletters, like Substack does.

It's still in an experimental stage, I'm not sure what direction this is going to go yet. I don't think it's valuable enough as long as it doesn't support displaying basic data like an image or quoted tweet, which the oEmbed API doesn't return by default.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/4b4270c2035abcbc3ed38e3824c0e8ee1fcd868f67c5a81165f90491749cc7d3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f747769747465722d6f656d6265642e6a70673f743d31)](https://spatie.be/github-ad-click/twitter-oembed)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/twitter-oembed
```

Usage
-----

[](#usage)

```
$tweet = (new TwitterOEmbed())->embed(
    'https://twitter.com/AoDespair/status/1173718972103090177'
);

echo $tweet->url;
// "https://twitter.com/AoDespair/status/1173718972103090177"

echo $tweet->name;
// "David Simon"

echo $tweet->username;
// "@AoDespair"

echo $tweet->html;
// "Have I seen The Wire?"

echo $tweet->date;
// 2019-09-16
```

Alternatives
------------

[](#alternatives)

- **[j7mbo/twitter-api-php](https://github.com/J7mbo/twitter-api-php):** A Twitter API wrapper. This returns a lot more data, but requires a developer account.
- **[embed/embed](https://github.com/oscarotero/Embed):** A generic oEmbed package. This supports retrieving oEmbed data from any source, like YouTube or Wikipedia. `spatie/twitter-oembed` aims to add Twitter specific features like parsing the tweet's date and author metadata.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance54

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (5 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (5 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (1 commits)")

---

Tags

apiembdphptwitter

### Embed Badge

![Health badge](/badges/spatie-twitter-oembed/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-twitter-oembed/health.svg)](https://phpackages.com/packages/spatie-twitter-oembed)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
