Skip to content

togatoga/goforces

Repository files navigation

goforces

Build Status GoDocGo Report Card

goforces is go package for the codeforces(http://codeforces.com/) api. Check the Usage

Install

go get github.com/togatoga/goforces

Usage

package main

import (
    "context"
    "fmt"

    "github.com/togatoga/goforces"
)

func main() {
    ctx := context.Background()
    //logger
    logger := log.New(os.Stderr, "*** ", log.LstdFlags)
    //Codeforces client
    api, _ := goforces.NewClient(logger)
    //Problems
    problems, _ := api.GetProblemSetProblems(ctx, &goforces.ProblemSetProblemsOptions{Tags: []string{"dp"}})
    fmt.Printf("%+v\n", problems)

    //Contest list
    contestList, _ := api.GetContestList(ctx, nil)
    fmt.Printf("%+v\n", contestList)

    //If you use authorized methods, you must set your key and secret
    api.SetAPIKey("<your key>")
    api.SetAPISecret("<your secret>")
    //User friends
    friends, _ := api.GetUserFriends(ctx, nil)
    fmt.Printf("%+v\n", friends)
}

The official codeforces api documentation is here

Documention

Read Godoc

License

MIT License