OpenAPIClient-php
Access Forem articles, users and other resources via API.
For a real-world example of Forem in action, check out DEV.
All endpoints that don't require authentication are CORS enabled.
Dates and date times, unless otherwise specified, must be in the RFC 3339 format.
Authentication
For more information, please visit https://dev.to/contact.
Installation & Usage
Requirements
PHP 7.2 and later.
Composer
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/bitween-software/dev-to-open-api-client.git"
}
],
"require": {
"bitween-software/dev-to-open-api-client": "*@dev"
}
}
Then run composer install
Manual Installation
Download the files and include autoload.php
:
<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
Getting Started
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: api_key
$config = Bitween\DevTo\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Bitween\DevTo\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer');
// Configure OAuth2 access token for authorization: oauth2
$config = Bitween\DevTo\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
// Configure OAuth2 access token for authorization: oauth2
$config = Bitween\DevTo\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new Bitween\DevTo\Api\AdminConfigurationApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
try {
$result = $apiInstance->getConfig();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AdminConfigurationApi->getConfig: ', $e->getMessage(), PHP_EOL;
}
API Endpoints
All URIs are relative to https://dev.to/api
Class | Method | HTTP request | Description |
---|---|---|---|
AdminConfigurationApi | getConfig | GET /admin/config | Admin config |
AdminConfigurationApi | upsertConfig | PUT /admin/config | Update Site-wide Config |
ArticlesApi | createArticle | POST /articles | Create a new article |
ArticlesApi | getArticleById | GET /articles/{id} | A published article by ID |
ArticlesApi | getArticleByPath | GET /articles/{username}/{slug} | A published article by path |
ArticlesApi | getArticles | GET /articles | Published articles |
ArticlesApi | getArticlesWithVideo | GET /videos | Articles with a video |
ArticlesApi | getUserAllArticles | GET /articles/me/all | User's all articles |
ArticlesApi | getUserArticles | GET /articles/me | User's articles |
ArticlesApi | getUserPublishedArticles | GET /articles/me/published | User's published articles |
ArticlesApi | getUserUnpublishedArticles | GET /articles/me/unpublished | User's unpublished articles |
ArticlesApi | updateArticle | PUT /articles/{id} | Update an article |
CommentsApi | getCommentById | GET /comments/{id} | Comment |
CommentsApi | getCommentsByArticleId | GET /comments | Comments |
FollowersApi | getFollowers | GET /followers/users | Followers |
FollowsApi | getFollowedTags | GET /follows/tags | Followed tags |
ListingsApi | createListing | POST /listings | Create a new listing |
ListingsApi | getListingById | GET /listings/{id} | A listing |
ListingsApi | getListings | GET /listings | Published listings |
ListingsApi | getListingsByCategory | GET /listings/category/{category} | Published listings by category |
ListingsApi | updateListing | PUT /listings/{id} | Update a listing |
OrganizationsApi | getOrgArticles | GET /organizations/{username}/articles | Organization's Articles |
OrganizationsApi | getOrgListings | GET /organizations/{username}/listings | Organization's listings |
OrganizationsApi | getOrgUsers | GET /organizations/{username}/users | Organization's users |
OrganizationsApi | getOrganization | GET /organizations/{username} | An organization |
PodcastEpisodesApi | getPodcastEpisodes | GET /podcast_episodes | Published podcast episodes |
ProfileImagesApi | getProfileImage | GET /profile_images/{username} | User or organization profile picture |
ReadinglistApi | getReadinglist | GET /readinglist | User's reading list |
TagsApi | getFollowedTags | GET /follows/tags | Followed tags |
TagsApi | getTags | GET /tags | Tags |
UsersApi | getUser | GET /users/{id} | A user |
UsersApi | getUserAllArticles | GET /articles/me/all | User's all articles |
UsersApi | getUserArticles | GET /articles/me | User's articles |
UsersApi | getUserMe | GET /users/me | The authenticated user |
UsersApi | getUserPublishedArticles | GET /articles/me/published | User's published articles |
UsersApi | getUserUnpublishedArticles | GET /articles/me/unpublished | User's unpublished articles |
VideosApi | getArticlesWithVideo | GET /videos | Articles with a video |
WebhooksApi | createWebhook | POST /webhooks | Create a new webhook |
WebhooksApi | deleteWebhook | DELETE /webhooks/{id} | A webhook endpoint |
WebhooksApi | getWebhookById | GET /webhooks/{id} | A webhook endpoint |
WebhooksApi | getWebhooks | GET /webhooks | Webhooks |
Models
- APIError
- ArticleCreate
- ArticleCreateArticle
- ArticleFlareTag
- ArticleIndex
- ArticleMe
- ArticleShow
- ArticleUpdate
- ArticleUpdateArticle
- ArticleVideo
- ArticleVideoUser
- Comment
- FollowedTag
- Follower
- Listing
- ListingCategory
- ListingCreate
- ListingCreateListing
- ListingUpdate
- ListingUpdateListing
- Organization
- PodcastEpisode
- PodcastEpisodePodcast
- ProfileImage
- ReadingList
- SharedOrganization
- SharedUser
- SiteConfig
- Tag
- User
- WebhookCreate
- WebhookCreateWebhookEndpoint
- WebhookIndex
- WebhookShow
Authorization
api_key
- Type: API key
- API key parameter name: api-key
- Location: HTTP header
oauth2
-
Type:
OAuth
-
Flow:
application
- Authorization URL: ``
- Scopes: N/A
oauth2
-
Type:
OAuth
-
Flow:
accessCode
-
Authorization URL:
https://dev.to/oauth/authorize
- Scopes: N/A
Tests
To run the tests, use:
composer install
vendor/bin/phpunit
Author
About this package
This PHP package is automatically generated by the OpenAPI Generator project:
- API version:
0.9.5
- Build package:
org.openapitools.codegen.languages.PhpClientCodegen