Skip to content

DEV is a community of software developers where they can share knowledge, collaborate, and learn from each other. It's a platform for writing, reading, and discussing code and software development topics. DEV also provides resources, tools, and opportunities for developers to grow their skills and network with industry professionals.

Notifications You must be signed in to change notification settings

konfig-sdks/dev-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visit Dev

Access Forem articles, users and other resources via API. For a real-world example of Forem in action, check out DEV. All endpoints can be accessed with the 'api-key' header and a accept header, but some of them are accessible publicly without authentication.

    Dates and date times, unless otherwise specified, must be in
    the [RFC 3339](https://tools.ietf.org/html/rfc3339) format.

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven (3.8.3+)/Gradle (7.2+)

If you are adding this library to an Android Application or Library:

  1. Android 8.0+ (API Level 26+)

Installation

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>com.konfigthis</groupId>
  <artifactId>dev-java-sdk</artifactId>
  <version>1.0.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your build.gradle:

// build.gradle
repositories {
  mavenCentral()
}

dependencies {
   implementation "com.konfigthis:dev-java-sdk:1.0.0"
}

Android users

Make sure your build.gradle file as a minSdk version of at least 26:

// build.gradle
android {
    defaultConfig {
        minSdk 26
    }
}

Also make sure your library or application has internet permissions in your AndroidManifest.xml:

<!--AndroidManifest.xml-->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/dev-java-sdk-1.0.0.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

import com.konfigthis.client.ApiClient;
import com.konfigthis.client.ApiException;
import com.konfigthis.client.ApiResponse;
import com.konfigthis.client.Dev;
import com.konfigthis.client.Configuration;
import com.konfigthis.client.auth.*;
import com.konfigthis.client.model.*;
import com.konfigthis.client.api.ArticlesApi;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class Example {
  public static void main(String[] args) {
    Configuration configuration = new Configuration();
    configuration.host = "https://dev.to/api";
    
    configuration.apiKey  = "YOUR API KEY";
    Dev client = new Dev(configuration);
    ArticleArticle article = new ArticleArticle();
    try {
      ArticlesCreateNewArticleResponse result = client
              .articles
              .createNewArticle()
              .article(article)
              .execute();
      System.out.println(result);
      System.out.println(result.getTags());
      System.out.println(result.getTitle());
      System.out.println(result.getDescription());
      System.out.println(result.getTypeOf());
      System.out.println(result.getId());
      System.out.println(result.getReadablePublishDate());
      System.out.println(result.getSlug());
      System.out.println(result.getPath());
      System.out.println(result.getUrl());
      System.out.println(result.getCommentsCount());
      System.out.println(result.getPublicReactionsCount());
      System.out.println(result.getCollectionId());
      System.out.println(result.getPublishedTimestamp());
      System.out.println(result.getPositiveReactionsCount());
      System.out.println(result.getCoverImage());
      System.out.println(result.getSocialImage());
      System.out.println(result.getCanonicalUrl());
      System.out.println(result.getCreatedAt());
      System.out.println(result.getEditedAt());
      System.out.println(result.getCrosspostedAt());
      System.out.println(result.getPublishedAt());
      System.out.println(result.getLastCommentAt());
      System.out.println(result.getReadingTimeMinutes());
      System.out.println(result.getTagList());
      System.out.println(result.getBodyHtml());
      System.out.println(result.getBodyMarkdown());
      System.out.println(result.getUser());
    } catch (ApiException e) {
      System.err.println("Exception when calling ArticlesApi#createNewArticle");
      System.err.println("Status code: " + e.getStatusCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }

    // Use .executeWithHttpInfo() to retrieve HTTP Status Code, Headers and Request
    try {
      ApiResponse<ArticlesCreateNewArticleResponse> response = client
              .articles
              .createNewArticle()
              .article(article)
              .executeWithHttpInfo();
      System.out.println(response.getResponseBody());
      System.out.println(response.getResponseHeaders());
      System.out.println(response.getStatusCode());
      System.out.println(response.getRoundTripTime());
      System.out.println(response.getRequest());
    } catch (ApiException e) {
      System.err.println("Exception when calling ArticlesApi#createNewArticle");
      System.err.println("Status code: " + e.getStatusCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Documentation for API Endpoints

All URIs are relative to https://dev.to/api

Class Method HTTP request Description
ArticlesApi createNewArticle POST /api/articles Publish article
ArticlesApi getAllUserArticles GET /api/articles/me/all User's all articles
ArticlesApi getById GET /api/articles/{id} Published article by id
ArticlesApi getByPath GET /api/articles/{username}/{slug} Published article by path
ArticlesApi getPublishedList GET /api/articles/me User's articles
ArticlesApi getPublishedList_0 GET /api/articles/me/published User's published articles
ArticlesApi getUnpublishedList GET /api/articles/me/unpublished User's unpublished articles
ArticlesApi listArticles GET /api/organizations/{organization_id_or_username}/articles Organization's Articles
ArticlesApi listByPopularity GET /api/videos Articles with a video
ArticlesApi listLatestPublished GET /api/articles/latest Published articles sorted by published date
ArticlesApi listPublishedArticles GET /api/articles Published articles
ArticlesApi unpublishById PUT /api/articles/{id}/unpublish Unpublish an article
ArticlesApi updateById PUT /api/articles/{id} Update an article by id
BillboardsApi createNewBillboard POST /api/billboards Create a billboard
BillboardsApi getById GET /api/billboards/{id} A billboard (by id)
BillboardsApi getList GET /api/billboards Billboards
BillboardsApi unpublishBillboard PUT /api/billboards/{id}/unpublish Unpublish a billboard
BillboardsApi updateById PUT /api/billboards/{id} Update a billboard by ID
CommentsApi getAllThreaded GET /api/comments Comments
CommentsApi getThreadedComment GET /api/comments/{id} Comment by id
FollowedTagsApi getTagList GET /api/follows/tags Followed Tags
FollowersApi getList GET /api/followers/users Followers
OrganizationsApi createNewOrganization POST /api/organizations Create an Organization
OrganizationsApi deleteById DELETE /api/organizations/{id} Delete an Organization by id
OrganizationsApi getById GET /api/organizations/{id} An organization (by id)
OrganizationsApi getByUsername GET /api/organizations/{username} An organization (by username)
OrganizationsApi listArticles GET /api/organizations/{organization_id_or_username}/articles Organization's Articles
OrganizationsApi listOfDev GET /api/organizations Organizations
OrganizationsApi listUsers GET /api/organizations/{organization_id_or_username}/users Organization's users
OrganizationsApi updateById PUT /api/organizations/{id} Update an organization by id
PagesApi createNewPage POST /api/pages pages
PagesApi getDetails GET /api/pages/{id} show details for a page
PagesApi listAllDetails GET /api/pages show details for all pages
PagesApi removePageById DELETE /api/pages/{id} remove a page
PagesApi updatePageDetails PUT /api/pages/{id} update details for a page
PodcastEpisodesApi listByDescendingPublicationDate GET /api/podcast_episodes Podcast Episodes
ProfileImagesApi getByUsername GET /api/profile_images/{username} A Users or organizations profile image
ReactionsApi createReaction POST /api/reactions create reaction
ReactionsApi toggleUserReaction POST /api/reactions/toggle toggle reaction
ReadinglistApi getUserReadinglist GET /api/readinglist Readinglist
SegmentsApi addUsersToSegment PUT /api/segments/{id}/add_users Add users to a manually managed audience segment
SegmentsApi createManuallyManagedSegment POST /api/segments Create a manually managed audience segment
SegmentsApi deleteManuallyManagedSegment DELETE /api/segments/{id} Delete a manually managed audience segment
SegmentsApi getById GET /api/segments/{id} A manually managed audience segment
SegmentsApi getUserListInSegment GET /api/segments/{id}/users Users in a manually managed audience segment
SegmentsApi listAudienceSegments GET /api/segments Manually managed audience segments
SegmentsApi removeUsersFromSegment PUT /api/segments/{id}/remove_users Remove users from a manually managed audience segment
TagsApi getTagList GET /api/follows/tags Followed Tags
TagsApi listByPopularity GET /api/tags Tags
UsersApi addLimitedRole PUT /api/users/{id}/limited Add limited role for a User
UsersApi addTrustedRole PUT /api/users/{id}/trusted Add trusted role for a User
UsersApi assignSpamRole PUT /api/users/{id}/spam Add spam role for a User
UsersApi getAllUserArticles GET /api/articles/me/all User's all articles
UsersApi getByIdOrUsername GET /api/users/{id} A User
UsersApi getInformation GET /api/users/me The authenticated user
UsersApi getPublishedList GET /api/articles/me User's articles
UsersApi getPublishedList_0 GET /api/articles/me/published User's published articles
UsersApi getUnpublishedList GET /api/articles/me/unpublished User's unpublished articles
UsersApi inviteUser POST /api/admin/users Invite a User
UsersApi listUsers GET /api/organizations/{organization_id_or_username}/users Organization's users
UsersApi removeLimits DELETE /api/users/{id}/limited Remove limited for a User
UsersApi removeSpamRole DELETE /api/users/{id}/spam Remove spam role from a User
UsersApi removeTrustedRole DELETE /api/users/{id}/trusted Remove trusted role from a User
UsersApi suspendUser PUT /api/users/{id}/suspend Suspend a User
UsersApi unpublishUserArticlesAndComments PUT /api/users/{id}/unpublish Unpublish a User's Articles and Comments
VideosApi listByPopularity GET /api/videos Articles with a video

Documentation for Models

Author

This Java package is automatically generated by Konfig

About

DEV is a community of software developers where they can share knowledge, collaborate, and learn from each other. It's a platform for writing, reading, and discussing code and software development topics. DEV also provides resources, tools, and opportunities for developers to grow their skills and network with industry professionals.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published