Export using default CSV options via API #6184

Closed
opened 2025-12-29 19:37:49 +01:00 by adam · 2 comments
Owner

Originally created by @joachimtingvold on GitHub (Mar 9, 2022).

NetBox version

v3.1.1

Feature type

Change to existing functionality

Proposed functionality

Be able to use the default exports ("All Data" and "Current View") from the API.

https://netbox.foo.bar/x/y/?export
https://netbox.foo.bar/x/y/?export=table

Both URLs currently exports CSV (either all, or whatever filter/page you have).

https://netbox.foo.bar/api/x/y/?export
https://netbox.foo.bar/api/x/y/?export=table

Both URLs yield {"detail":"Not found."} as response. I'd expect the same CSV to be output via API.

Use case

Be able to export data quickly without having to define custom export templates. Useful for quick offline access or similar.

Database changes

No response

External dependencies

No response

Originally created by @joachimtingvold on GitHub (Mar 9, 2022). ### NetBox version v3.1.1 ### Feature type Change to existing functionality ### Proposed functionality Be able to use the default exports ("All Data" and "Current View") from the API. https://netbox.foo.bar/x/y/?export https://netbox.foo.bar/x/y/?export=table Both URLs currently exports CSV (either all, or whatever filter/page you have). https://netbox.foo.bar/api/x/y/?export https://netbox.foo.bar/api/x/y/?export=table Both URLs yield `{"detail":"Not found."}` as response. I'd expect the same CSV to be output via API. ### Use case Be able to export data quickly without having to define custom export templates. Useful for quick offline access or similar. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 19:37:49 +01:00
adam closed this issue 2025-12-29 19:37:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 9, 2022):

I'm afraid this isn't something we're going to implement. The CSV export is a function of the table object, which is an entirely separate execution path from how API responses are rendered. The expectation of a REST API in general is that an API consumer will request the data it needs and render it in the desired format locally.

@jeremystretch commented on GitHub (Mar 9, 2022): I'm afraid this isn't something we're going to implement. The CSV export is a function of the table object, which is an entirely separate execution path from how API responses are rendered. The expectation of a REST API in general is that an API consumer will request the data it needs and render it in the desired format locally.
Author
Owner

@joachimtingvold commented on GitHub (Mar 9, 2022):

Would it not be fairly simple to mimic the CSV output using Jinja-templates, and just have some default ones for each endpoint that can be used when using ?export without specifying any export template? (i.e. a built-in default template, more or less).

edit1; Point being; would be nice to have an easy way to export human readable info, without having to manually create a lot of export templates. Sure, would be fairly easy to create CSV from JSON, but would be nice to have a quick and easy way to do it built-in.

edit2; It could even be done using ?format=csv as well, rather than via the ?export, which would probably make more sense?

@joachimtingvold commented on GitHub (Mar 9, 2022): Would it not be fairly simple to mimic the CSV output using Jinja-templates, and just have some default ones for each endpoint that can be used when using `?export` without specifying any export template? (i.e. a built-in default template, more or less). edit1; Point being; would be nice to have an easy way to export human readable info, without having to manually create a lot of export templates. Sure, would be fairly easy to create CSV from JSON, but would be nice to have a quick and easy way to do it built-in. edit2; It could even be done using `?format=csv` as well, rather than via the `?export`, which would probably make more sense?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6184