DEV Community

Cover image for Dev.to API 002 - Creating a Post
Rodrigo Cordeiro
Rodrigo Cordeiro

Posted on

6

Dev.to API 002 - Creating a Post

002 - Creating a Post with the API

Ok, now we already know what to do to get the feed and the basic to work with the API, so, now we're going to post something using the API. To this, we must send a POST request to /articles with a the information about the post, see all the parameters possibilities at the api documentation.

curl

curl --request POST  
--url https://dev.to/api/articles  
--header 'api-key: YOUR_API_TOKEN'  
--header 'content-type: application/json'  
--data '{ 
 "article": { 
     "title": "Creating new post", 
     "published": true, 
     "body_markdown": "Hey there, here go some post.", 
     "tags": [ 
         "todayilearned", 
         "showdev" 
     ]
 }
}'

node

var unirest = require("unirest");

unirest.post('https://dev.to/api/articles')
 .type('json')
 .headers({
   'api-key':'YOUR_API_TOKEN'
 })
 .send({
   "article": {
     "title": "Creating new post",
     "published": true,
     "body_markdown": "Hey there, here go some post.",
     "tags": [
       "todayilearned",
       "showdev"
     ]
   }
 })
 .then((response)=>{
   console.log(response.body)
 })

That's all folks!! You can see all the steps on my documentation.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay