Add More API End Points


#1

I am Big Fan of Ghost API :100:

ADD

  • Random Posts (with limits)
  • Tags

Add Trusted Domain Registration Option on Ghost Admin Panel


#2

Could you explain what you’re after in a little bit more detail?

I don’t know of any other API that offers random data - it’s normal to generate that client side.

Tags are also already offered via the API, so could you explain what you haven’t been able to do?


#3

On the topic of api endpoints, will we be seeing the ability to publish new, edit existing posts via api?


#4

Display Random Posts via API

Example

https://example.com/ghost/api/v0.1/posts/?formats=plaintext&client_id=ghost-frontend&client_secret=xxxxxxxxxxxx&method=random&limit=1

#5

I Build a Quotes website on Ghost
I provide a Public API to My Users (Currently I add CORS Via add_header Method)

Currently, I need this Below Options

  • Add trusted domain from Ghost Admin Panel
  • Display Random Posts via API URL (useful one While Build a CLI or Widgets)

#6

Sorry @mskian I wasn’t asking you to give an example of how it might work. I am saying I do not know of any API of any software or service which offers random data.

We have plans to review API authentication including trusted domains and also writing to the API, but not for a few more months at least. However cc @gcordalis it is currently possible to do anything that Ghost Admin can do via the API, it’s just not “official” yet and therefore likely to change.


#7

Sorry
the Random Post endpoint for Display the Random Post Results via JSON


#8

Thanks for clarifying - are there any docs about Ghost Admin or should I dig deep and have a look at how it runs?


#9

Best thing to do is open Chrome DevTools whilst using the admin area to do the actions you want to automate, you’ll then be able to inspect the API requests in the Network tab.

There are also docs for user authentication that explain how to get the necessary tokens to make private API requests.

If you decide to use the private API just be aware that it’s private so that we can change it as needed. Hannah already mentioned above that we’ll be looking to overhaul the authentication in the not too distant future, we also want to look at changing how URLs are output so that they are more useful for external clients.


Create Post API
#10

Thanks Kevin and Hannah, this should be everything I need to get started.

I’m not too worried about the Private API changing, this is just a stopgap solution until I have the time to put a proper solution in place.

EDIT:
Hey @Kevin, I know this isn’t supported so understand if you can’t help with this - I’m running into the ‘UpdateCollisionError’ - I’m pretty confident the requests I’m making are correct but I can’t seem to get around it. Do you have any suggestions for how to get around this conflict?


#11

That error occurs when the updated_at value of a post that is sent to the server does not match the updated_at value that is stored in the database for that post.

You can see the implementation here, the protection is in place to prevent an accidental overwrite of a post with an old version either due to keeping the admin open and using an old tab or when multiple people have edited a post.


#12

Champion, thanks so much!