Add More API End Points

I am Big Fan of Ghost API :100:

ADD

  • Random Posts (with limits)
  • Tags

Add Trusted Domain Registration Option on Ghost Admin Panel

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?

1 Like

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

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
1 Like

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)

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.

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

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

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.

1 Like

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?

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.

Champion, thanks so much!

Tumblr does that. You could go to any Tumblr blog, and open up the /random endpoint, which will then cause a redirect to a certain post.

Example: http://micro.preslav.me/random

Itā€™s a neat way of allowing people to stumble upon interesting content from the past.

i sugest avoid this approach in favor of etag and conditional request, because its rest complient , flexible and is a protocol already defined.

in this way the knowledge of rest is reuset else need to know a specificity of ghostjs api.