Format of doc fetche via API is different from exported via (import/export) option

Hi Sam,
We are trying to take the backup of all the documents and custom type to our AWS bucket using Ruby on Rails application. Our plan is to use those backup files via Prismic import/export (Import/Export - Documentation - Prismic) when needed.
Issue:
The json format of documents fetch via API is different from the format exported via prismic import/export option.

Questions:

  1. Is there any better alternative way to use prismic (import/export)feature via API.
  2. If no, then how can I fetch the Prismic document in same format as documents exported via (import/export) option.

Code snippet we are using

      api = Prismic.api(
        "https://test.prismic.io/api/v1",
        access_token: '',
        api_cache: CACHE,
        cache: CACHE
      )

  docs = api.query(Prismic::Predicates.at("document.type", 'doc_type'),
                        { "pageSize" => PAGE_SIZE, "page" => page_number })

docs.results.map { |doc| upload_to_aws_bucket(doc.to_json, "#{custom_type}/#{doc.id}.json") }

Format of document fetched via api mentioned above

[
    ["key", { "value": "value" }],
    [
      "body",
      {
        "slices": [
          {
            "slice_type": "slice #1",
            "slice_label": null,
            "non_repeat": {
              "title": {
                "blocks": [
                  {
                    "text": "text",
                    "spans": [],
                    "label": null
                  }
                ]
              },
              "description": {
                "blocks": [
                  {
                    "text": " description",
                    "spans": [],
                    "label": null
                  }
                ]
              }
            },
            "repeat": []
          },
          {
            "slice_type": "slice #2",
            "slice_label": null,
            "non_repeat": {
              "heading": { "value": "" },
              "description": {
                "value": ""
              },
              "cta_text": { "value": "" }
            },
            "repeat": []
          }
        ]
      }
    ]
  ]
]

Regards
Vishal Verma

Hello @vishal.verma, thanks for sharing your use case.

Import / Export is the only tool that allows you to return your documents in JSON format. Otherwise, the other option you have to 'back up' your content is to use your repository’s API endpoint as you normally do to query your documents and use the Custom Types API to return the content modeling structure of documents.

Hi @Pau, thanks for the reply.
Yes, I am able to fetch documents using prismic.io ruby gem (prismic.io | RubyGems.org | your community gem host), but the issues is with the format of the JSON.

The import tool accepts JSON in same structure as output from an export.
So my question is how can I fetch the doc with structure similar to export tool?

Thanks for the response.
In this case, the export tool is the only option to retrieve your docs in JSON format.