Skip to content

Getting started

Warning

Please note that as this is an alpha version, some features may be limited or unstable. We appreciate your patience and understanding as we continue to work towards making our service even better.

1 - Explore endpoints

Let's start by exploring the Free Trials endpoints, which offer a chance to test and retrieve some basic information from the API. Through this exploration, you'll learn how to interact with the Swagger interactive interface and make practical use of its features.

These endpoints don't require authentication, making them a straightforward starting point to get acquainted with the service before diving deeper.

  • Begin by visiting the Swagger interface at this link: https://api.lotteryresultsapi.com/freetrial/docs

    The Swagger interface provides an overview of all available endpoints in the service, each accompanied by a brief description to help understand its purpose.

Getting started free-trial : swagger interface
  1. Click on the first endpoint.

    This endpoint /lottery allows searching for the available lotteries.

    To enter interactive mode, click on Try it out button.

Getting started free-trial : first endpoint (lottery)
  1. You can edit parameters in this section, such as offset and limit, to manage pagination when dealing with a large amount of data.
Getting started free-trial : endpoint editable query parameter section
  1. Click the Execute button.

    Swagger will make a call to the API, and you'll see the details of the request and the HTTP response code (typically 200 OK) below.

    The response content is available in the Response Body section.

Getting started free-trial : interactive mode buttons

That's it! You've now learned how to interact with the API using Swagger interface. Feel free to explore other available endpoints.

With this basic understanding, we can now move on to using endpoints to retrieve more detailed lottery draw information.

2 - Explore real endpoints

Info

The freetrials endpoints are mainly intended for better understanding of the API's functionality and the use of the interactive Swagger interface without the need for authentication.

Now that you've understood how to use the Swagger interface, let's see how to access API information. First, we'll see how to retrieve an authentication token, then we'll provide two examples for fetching the latest French lotto draw numbers.

Authentication

Note

Lottery Results API applications use the third-party service Auth0 for authentication management. Lottery Results API does not store or have access to users' passwords.

To retrieve information related to lotteries, it's necessary to create a token that will authenticate you for each request to the API.

To create a token:

  1. Register to the website https://www.lotteryresultsapi.com with the Register button (you can use Google or Github account to authenticate).
  2. Once registered, you'll be redirected to your profile page where you can view various account information.
  3. On the right, a form allows you to create a token that will be used for the API.
    • Enter a token name (e.g., myToken)
    • Press the Create button

      Once done, a message will indicate the secret that you'll use in API calls. Note that the value is displayed only once. If you forget the secret, you can delete it and create a new token.

Get informations of lottery

Once the token is created, we can connect to the Swagger web interface (https://api.lotteryresultsapi.com/docs) to test the retrieval of lottery-related information.

First, let's enter the token in the web interface:

  1. Click on the Authorize button at the top right and enter the value of the token previously generated in the X-API-Token field.
Getting started : Swagger authenticate endpoint request
Getting started : Swagger authenticate endpoint request
  1. Authorize and close the popup with the close button.

Now, we can use the various endpoints to retrieve the data.

Let's take the example of retrieving the numbers from the latest French lotto draw:

  1. Just like with the 'freetrials' endpoints, search for and click on the endpoint /lottery/{tag}/draw/latest
  2. Enter in interactive mode : click on Try it out button.
  3. Click the Execute button. Swagger will make a call to the API, and you'll see the results in body response section.

Tip

If you encounter an error during your request, don't hesitate to browse the error page to better understand what the error is : Documentation > API > Erros

Getting started :

Note

You can notice that the Swagger interface displays the cURL command, so that you can rerun the command in a terminal.

Querying the API with cURL

The Swagger interface is a good way to better understand the API's functionality interactively and to discover all available features.

Here's a simple example with cURL to retrieve the values of the latest French lotto draw:

  • Endpoint to use : /lottery/{tag}/draw/latest
  • Lottery tag : fr_lotto

Request :

curl -H 'X-API-Token: MY_SECRET_TOKEN' \
    https://api.lotteryresultsapi.com/lottery/fr_lotto/draw/latest

Response :

{
    "date": "2024-05-18",
    "numbers": "14 34 37 15 45 2"
}
About this endpoint

The endpoint /lottery/{tag}/draw/latest allows you to retrieve the latest available lottery draw as a string containing all the draw numbers. Depending on the type of lottery, one or more numbers at the end correspond to the special number, often called the lucky number.

Alpha version

The format of the draw numbers return may change after the alpha version.

To go further

To sum it up, this guide has given you the basics to start using our service with confidence. You've learned how to navigate the API, authenticate your access, and get the data you need.

To take your understanding further, feel free to explore our documentation or follow the links below.