medium
Medium is an online publishing platform.
Usage
import { medium } from 'netzo/apis/medium.ts'
const api = medium({
accessToken: Deno.env.get('MEDIUM_ACCESS_TOKEN'),
})
Configuration
The medium
factory function expects an object with the following, and returns an object with an API client api
.
Param | Type | Default | Description |
---|---|---|---|
accessToken | string | Deno.env.get('MEDIUM_ACCESS_TOKEN') | the token to use for authentication |
Refer to the API documentation to get the required information.
Examples
The following examples assume you have created an api client instance.
Find publications
Find all publications a user is subscribed to, writes to, or edits.
const result = await api.users[USER_ID].publications.get<Publications>()
const resultData = result.data
Get user
Get the authenticated user's info.
const result = await api.me.get<User>()
const resultData = result.data
Add post
Create a post to the authenticated user's profile.
const data: DataAddPost = {
title: 'New Post',
contentFormat: 'html',
content: '<h1>New title</h1><p>This is new post content</p>'
}
const result = await api.users[AUTHOR_ID].posts.post<Post>(data)
const resultData = result.data