jnelle / MyFitnesspal-API-Golang

This is an unofficial API wrapper for MyFitnessPal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(Unofficial) MyFitnessPal Golang API Wrapper

This is an unofficial MyFitnessPal API Wrapper which uses the "internal" MyFitnessPal APIs and not the official one.

Installation

go get -u github.com/jnelle/MyFitnesspal-API-Golang

How to use it?

Example with credentials

import "github.com/jnelle/MyFitnesspal-API-Golang/app/client"

func main() {
	mfp := client.MFPClient{Username: "YOUR_EMAIL", Password: "YOUR_PASSWORD"}

	err := mfp.InitialLoad()
	if err != nil {
		log.Fatalln(err)
	}

	food, err := mfp.SearchFoodWithoutPagination("Pizza")
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println(food.Items[0])

}

Example without credentials

import "github.com/jnelle/MyFitnesspal-API-Golang/app/client"

func main() {
	mfp := client.MFPClient{}

	// Example without using credentials and with pagination
	resultOffset, err := mfp.SearchFoodWithoutAuth("Pizza", 5, 1)
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(resultOffset)

	resultOffset, err = mfp.SearchFoodWithoutAuth("Pizza", 10, 2)
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(resultOffset)


}

TODOS

  • Add pagination for searchfood method with credentials
  • For additional features just create an issue

About

This is an unofficial API wrapper for MyFitnessPal

License:GNU General Public License v3.0


Languages

Language:Go 100.0%