<commit_before># CoinMarketCap API client library

Simple API client library for the CoinMarketCap API, written in Go

## Installation

This is not a standalone app, use it in your project as a package. To get it simply run;
`go get github.com/shaunmza/coinmarketcap`

## Usage

There is an example file in the `examples` directory, it should be pretty much
self explanatory, snippet from the file below;

```go

var r data.Ticker

// Initialse, so we can get the channel to receive updates from
tChan := coinmarketcap.Init()

// Which coins do you want to watch?
t := make([]string, 0)
t = append(t, "bitcoin")
t = append(t, "litecoin")
t = append(t, "steem")
t = append(t, "steem-dollars")

// Start watching, second parameter is period between updates
// Endpoints are updated every 5 minutes, se we use that here
coinmarketcap.WatchCoins(t, 60*5)

// Infinite loop so we keep getting prices
for {
  // Get off of the channel
  r = <-tChan

  // If this is not nil then we encountered a problem, use this to determine
  // what to do next.
  // LastUpdate can be used to determine how stale the data is
  if r.Error != nil {
    fmt.Printf("Error! %s, Last Updated: %s\n", r.Error, r.LastUpdate)
  }

  // Just print it out for now
  for _, coin := range r.Coins {
    fmt.Println("Symbol: '" + coin.Symbol + "', Name: '" +
      coin.Name + "', Price Bitcoin: '" +
      coin.PriceBtc + "', Price USD: '" + coin.PriceUsd + "'")
  }
}

```

The values for the coins to watch are the CoinMarketCap id's, which can be seen in the url when viewing details on the site.<commit_msg>Re-structure of data and code, not using channels anymore<commit_after># CoinMarketCap API client library

Simple API client library for the CoinMarketCap API, written in Go

## Installation

This is not a standalone app, use it in your project as a package. To get it simply run;
`go get github.com/shaunmza/coinmarketcap`

## Usage

There is an example file in the `examples` directory, it should be pretty much
self explanatory, snippet from the file below;

```go

var r coinmarketcap.Ticker
var err error

// Which coins do you want to watch?
t := make([]string, 0)
t = append(t, "bitcoin")
t = append(t, "litecoin")
t = append(t, "steem")
t = append(t, "steem-dollars")

// Endpoints are updated every 5 minutes, se we use that here
period := 10 // 60 * 5
ticker := time.NewTicker(time.Second * time.Duration(period))

// Because we are impatient, call it now
r, err = coinmarketcap.GetData(t)

// If this is not nil then we encountered a problem, use this to determine
// what to do next.
// LastUpdate can be used to determine how stale the data is
if err != nil {
  fmt.Printf("Error! %s, Last Updated: %s\n", err, r.LastUpdate)
}

printData(r)

// Infinite loop so we keep getting prices
for _ = range ticker.C {
  // Get off of the channel
  r, err = coinmarketcap.GetData(t)

  // If this is not nil then we encountered a problem, use this to determine
  // what to do next.
  // LastUpdate can be used to determine how stale the data is
  if err != nil {
    fmt.Printf("Error! %s, Last Updated: %s\n", err, r.LastUpdate)
  }
  printData(r)

}

```

The values for the coins to watch are the CoinMarketCap id's, which can be seen in the url when viewing details on the site.
{'fraction_non_alphanumeric': 0.10254055708601163, 'fraction_numerical': 0.0036730945821854912, 'mean_word_length': 3.482853223593964, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1709064', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1006, 'n_words': 466}