Not affiliated in any way with Ghost.org.
Ghost Client (ContentAPI + AdminAPI)
- Upload images
- Add post
- Get posts
- Update post
- Delete post
- Add page
- Get pages
- Update page
- Delete page
- Add tag
- Get tags
- Update tag
- Delete tag
- Add member
- Get members
- Update member
- Add image
package main
import (
"fmt"
"github.com/sklinkert/ghost"
)
func main() {
contentAPIToken := "837484..."
adminAPIToken := "90968696..."
ghostAPI := ghost.New("https://example.com", contentAPIToken, adminAPIToken)
posts, err := ghostAPI.GetPosts()
if err != nil {
fmt.Printf("cannot get posts from ghost api: %v\n", err)
return
}
for _, post := range posts.Posts {
fmt.Println(post.Title)
// Update existing post
post.Title = "new title"
if err := ghostAPI.AdminUpdatePost(post); err != nil {
fmt.Printf("update failed: %v\n", err)
break
}
}
// Upload new image
imageURL, err := ghostAPI.AdminUploadImage("./myimage.jpg")
if err != nil {
fmt.Printf("Image upload failed: %v\n", err)
}
fmt.Println(imageURL)
}