Per-Locale Publishing status not available in plugins/CMA/CDA?

Is there a way to get the current status (publish,draft,new) of a specific locale of a record inside a plugin? I cannot find any corresponding method or field in the context objects passed to the various plugin hooks.

There is also no such info in the CMA. API or Content Delivery API…

Hi @martin.palma,

Officially, we only expose this info in the UI:

Now, unofficially, under the hood that uses a secret API that you can technically access yourself… however, that endpoint is deprecated (edit: actually, it’s new and still under development, i.e., “alpha”), undocumented, and subject to change at any time without warning (i.e. it may break tomorrow!). I’ll check with the devs about why this is deprecated unofficial, but for now, it’s very much “use at your own risk” – please don’t make any long-lasting scripts with it, because it may suddenly break without warning. That said, if you want to try it anyway, here are the details (click to unblur):

The API endpoint is: https://site-api.datocms.com/items/itemId/current-vs-published-state

Or in the CMA JS client as the deprecated method client.items.currentVsPublishedState(itemId, {nested: boolean})

That will get you a response like:

{
  "id": "181065759",
  "type": "item_current_vs_published_state",
  "current_version_locales": [
    "de",
    "en",
    "es",
    "fr",
    "it",
    "pt",
    "ru",
    "sv"
  ],
  "published_version_locales": [
    "de",
    "en",
    "es",
    "fr",
    "it",
    "pt",
    "ru",
    "sv"
  ],
  "changed_locales": [
    "fr"
  ],
  "added_locales": [],
  "removed_locales": [],
  "non_localized_fields_changed": true,
  "scheduled_publication": null,
  "scheduled_unpublishing": null,
  "published_version": {
    "id": "337327958",
    "type": "item_version"
  }
}

The fields changed_locales, added_locales, and removed_locales will show you locale changes. Additionally, non_localized_fields_changed will tell you whether there are also unlocalized fields that are not yet published. If you need to do a more detailed diff, you can compare versions manually using the item-version endpoint.

I’ll check with the devs to see if there’s a reason this is deprecated unofficial and whether there are any replacements planned. (Edit: Not immediately, see posts below. Maybe someday!) Hope that helps in the meantime?

Hey Roger,

thanks for your feedback. That’s unfortunate that such critical information isn’t exposed in a official API. Hopefully this will be become a stable API endpoint.

Would be nice if you could keep us updated what the response of the Dev team is…

Hey @martin.palma , the devs got back to me about this. A bit of both bad and good news…

Bad news: As for why it’s not official, turns out it’s actually just a matter of prioritization – this is a relatively new endpoint, and it just hasn’t been fully fleshed out yet. Dato is a relatively small company and the developers are working on many features and fixes at any given time, often with priority given to the most popular asks. Maybe this could be a feature request so they can see if others have the same need?

Now, some good news too: I was partially mistaken, and they clarified that the endpoint isn’t deprecated per se, just unpublicized. Maybe “alpha” would’ve been a better term. That means even though we don’t consider it ready for general public use yet (no docs, not enough polish, etc.), we have no plans to get rid of it. It’s still “use at your own risk”: We’re not trying to make it go away, but it’s not yet stable, and the request and response shapes may or may not change.

You are free to use it in the meantime, but maybe limit it to non-essential parts of the workflow, and maybe add robust error-checking to make sure the response comes back as you expect?

I know that wasn’t quite the response you were hoping for, and I’m sorry for that, but at least I hope the transparency can help you plan around it a bit?

And if it ever gets officially prioritized and released, we’ll let you know!

1 Like