Skip to content

Commit

Permalink
docs: Update API documentation (#8606)
Browse files Browse the repository at this point in the history
* docs: fix documentation issues about API

- fix broken links
- fix typos

* docs: improve documentation about image cropping

See https://openfoodfacts.slack.com/archives/C02LDQDDD/p1682079839516249?thread_ts=1681985028.141819&cid=C02LDQDDD
  • Loading branch information
raphael0202 committed Jun 27, 2023
1 parent 161e3e9 commit 6bdbed3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Open-source contributors develop our SDKs, and more contributions are welcome to

> **Warning**: Before exploring any SDK, please read the [Before You Start section](#before-you-start).
>
> Also, remember to check the [API Reference Documentation](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/) first to verify if the problem is in SDK implementation or in the API itself.
> Also, remember to check the [API Reference Documentation](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/) first to verify if the problem is in SDK implementation or in the API itself.
- [Cordova](https://github.com/openfoodfacts/openfoodfacts-cordova-app)
- [Dart](https://github.com/openfoodfacts/openfoodfacts-dart/blob/master/DOCUMENTATION.md), published on [pub.dev](https://pub.dev/packages/openfoodfacts)
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ref-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ add_brands

## Search for Products

[Reference documentation for search API](https://openfoodfacts.github.io/openfoodfacts-server/api/ref#tag/Read-Requests/operation/get-search)
[Reference documentation for search API](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#get-/api/v2/search)

### Get data for a list of products

You can use comma to seperate multiple values of a query paremeter. This allows you to make bulk requests. The product result can also be limited to specified data using `fields`.
You can use comma to separate multiple values of a query parameter. This allows you to make bulk requests. The product result can also be limited to specified data using `fields`.

```text
https://world.openfoodfacts.org/api/v2/search?code=3263859883713,8437011606013,6111069000451&fields=code,product_name
Expand Down
2 changes: 2 additions & 0 deletions docs/api/ref/requestBodies/crop_a_photo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ type: object
description: |
Select a photo and optionally crop/rotate it.
The origin of the cropping coordinates is the top-left corner.
Note that rotation is applied *before* cropping, so the cropping bounding box
is relative to the rotated image.
properties:
code:
type: string
Expand Down
12 changes: 6 additions & 6 deletions docs/api/tutorial-off-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Fist, be sure to see our [Introduction to the API](./index.md).

This basic tutorial shows you can get the Nutri-score of a product, for instance, to display it in a mobile app after scanning the product barcode. Let's use [Nutella Ferrero](https://world.openfoodfacts.net/product/3017624010701/nutella-nutella-ferrero) as the product example for this tutorial.

To get a product nutriscore, send a request to the [Get A Product By Barcode](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/#get-/api/v2/product/-barcode-) endpoint.
To get a product nutriscore, send a request to the [Get A Product By Barcode](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#get-/api/v2/product/-barcode-) endpoint.

### Authentication

Expand Down Expand Up @@ -106,7 +106,7 @@ The `product` object in the response now contains the extra fields to show how t
}
```

For more details, see the reference documentation for [Get A Product By Barcode](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/#get-/api/v2/product/-barcode-).
For more details, see the reference documentation for [Get A Product By Barcode](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#get-/api/v2/product/-barcode-).

<!-- Probably have a conclusion that links to the next possible topic eg filter countries using lc and cc-->

Expand Down Expand Up @@ -153,7 +153,7 @@ The WRITE operations in the OFF API require authentication. Therefore you need

> Sign up on the [Open Food Facts App](https://world.openfoodfacts.net/) to get your`user_id` and `password`if you don't have one.
To write data to a product, make a `POST` request to the [`Add or Edit A Product`](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/#post-/cgi/product_jqm2.pl) endpoint.
To write data to a product, make a `POST` request to the [`Add or Edit A Product`](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#post-/cgi/product_jqm2.pl) endpoint.

```text
https://world.openfoodfacts.net/cgi/product_jqm2.pl
Expand Down Expand Up @@ -222,15 +222,15 @@ Now, let's check if the Nutri-Score for 100% Real Orange Juice has been computed
}
```

For more details, see the reference documentation for [Add or Edit A Product](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/#post-/cgi/product_jqm2.pl)
For more details, see the reference documentation for [Add or Edit A Product](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#post-/cgi/product_jqm2.pl)

You can also check the reference cheatsheet to know how to add/edit other types of product data.

<!-- Include the link of the cheatsheet once it is published. -->

## Search for a Product by Nutri-score

Using the Open Food Facts API, you can filter products based on different criteria. To search for products in the Orange Juice category with a nutrition_grade of `c`, query the [Search for Products endpoint](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/#get-/api/v2/search).
Using the Open Food Facts API, you can filter products based on different criteria. To search for products in the Orange Juice category with a nutrition_grade of `c`, query the [Search for Products endpoint](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#get-/api/v2/search).

### Describing the Search Request

Expand Down Expand Up @@ -353,4 +353,4 @@ The date that each product was last modified is now used to order the product re
}
```

To see other examples of sorting a search response, see the reference documentation for [Search for Products](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/#get-/api/v2/search).
To see other examples of sorting a search response, see the reference documentation for [Search for Products](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#get-/api/v2/search).
2 changes: 1 addition & 1 deletion docs/api/tutorial-uploading-photo-to-a-product.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The barcode of the product.

### Describing the Post Request

To upload photos to a product, make a `POST` request to the [`Add a Photo to an Existing Product`](https://openfoodfacts.github.io/openfoodfacts-server/api/ref/#post-/cgi/product_image_upload.pl) endpoint.
To upload photos to a product, make a `POST` request to the [`Add a Photo to an Existing Product`](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#post-/cgi/product_image_upload.pl) endpoint.

```text
https://off:off@world.openfoodfacts.net/cgi/product_image_upload.pl
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/api-rapidoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li><a href="https://openfoodfacts.github.io/openfoodfacts-server/api/">API Introduction</a></li>
<li><a href="https://openfoodfacts.github.io/openfoodfacts-server/api/#tutorials">API Tutorials</a></li>
<li><a href="https://openfoodfacts.github.io/openfoodfacts-server/api/ref-cheatsheet/">API Cheat sheet</a></li>
<li><a href="https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/">API v3</a></li>
<li><a href="https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v3/">API v3</a></li>
</ul>
</nav>
</nav>
Expand Down

0 comments on commit 6bdbed3

Please sign in to comment.