Skip to content

Latest commit

 

History

History
122 lines (87 loc) · 3.21 KB

README.md

File metadata and controls

122 lines (87 loc) · 3.21 KB

🤯 Free Public APIs API

Go Reference Official Documentation OpenAPI Go Report Card Code Coverage API Health License: MIT

FreePublicAPIs now has a free public API! The Free Public APIs API provides up-to-date information on every free public API listed on freepublicapis.com. Perfect for developers, students and hobbyists. It is limited to 1000 requests a day, if you need more, feel free to reach out. Also if you build something with this API, make sure to add it as a showcase project here. (Source)

Installation

To install the library, use the following command:

go get github.com/go-api-libs/freepublicapis/pkg/freepublicapis

Usage

Example 1: Get a Random API

package main

import (
	"context"

	"github.com/go-api-libs/freepublicapis/pkg/freepublicapis"
)

func main() {
	c, err := freepublicapis.NewClient()
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	simpleAPIInfo, err := c.GetRandom(ctx)
	if err != nil {
		panic(err)
	}

	// Use simpleAPIInfo object
}

Example 2: Get a Specific API by ID

package main

import (
	"context"

	"github.com/go-api-libs/freepublicapis/pkg/freepublicapis"
)

func main() {
	c, err := freepublicapis.NewClient()
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	simpleAPIInfo, err := c.GetAPI(ctx, 275)
	if err != nil {
		panic(err)
	}

	// Use simpleAPIInfo object
}

Example 3: List APIs with Parameters

package main

import (
	"context"

	"github.com/go-api-libs/freepublicapis/pkg/freepublicapis"
)

func main() {
	c, err := freepublicapis.NewClient()
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	apiInfos, err := c.ListApis(ctx, &freepublicapis.ListApisParams{
		Limit: 10,
		Sort:  "best",
	})
	if err != nil {
		panic(err)
	}

	// Use apiInfos array
}

Additional Information

Contributing

If you have any contributions to make, please submit a pull request or open an issue on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.