API Chatter

Our own Blood Bowl stats/fixtures database system.

Moderator: Area Leader

User avatar
Gandalf
Moderator
Moderator
Posts: 2064
Joined: Sat Nov 24, 2012 1:44 am

Re: API Chatter

Postby Gandalf » Thu Feb 18, 2016 12:21 pm

the names of the players who scored?

Yes
And the half time score?

No, however, once development on the dice logs is complete I will be able to provide this, along with what turn the players scored - or at least, my best guess of when that was, things like the clock going forwards/backwards a turn, or people doing the sum total of nothing on their turn will screw it up.

There is a pending change to do that will bring the "end of normal time" score into the database though - for use in cup matches. That's going to come along first, it's not too tricky to do.

I propose a structure like this for a matchreport API.
{ home_score : 2
, home_passes : 5
... and so on, like the current file
, touchdowns {
1 : { scorer : Ernie
, team : home
, turn : 6
, method : pass catch (possible options = pass catch, hand-off, pickup, interception, run in, depending on what they did on the turn they scored)
}
2 : { scorer : Alan
, team : home
, turn : 14
}
}
}

As mentioned, the touchdowns will just have the scorer for now, but may as well build the structure of the API to make future expansion easy.

Other possibilities I could do now that may be of interest for the match report...
- player with most yards run (overall? per team?)
- player with most yards passed (overall? per team?)
- most violent player (overall? per team? can be most casualties caused, but I'd prefer something like most knockdowns inflicted (ie armour breaks))

But I am wary of having too much data on one image.

If you want the API structure different then let me know. I can do one record per team and do away with the home_ and away_ prefixes easily enough - in fact that's how it's stored in the DB, but I found the home_ and away_ prefixes to be easier for building the matchreport web page. After all there will never be more than 2 teams in a game of blood bowl.

Then the coach writing the report gets to choose which images or combination thereof to use in his report. For example, starting with the main score image, writing a bit of report, then following up with some stats/dice analysis below. It would at least let us break up the walls of text we write sometimes.

Long-term it's been suggested that match reports are written to the website. It'll be another tab on the match report page. Obviously I need to set user logons and such first. Then you can see *all* the data pertaining to the match and the report, all in one place.

My personal opinion is that that's good, you can go back & relive matches, but having a summary image & the match report on the forums is good too, for a few reasons, eg this is a better place to discuss things, and it means they are all in the same place for readers to look at after a weekend's matches.

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Thu Feb 18, 2016 1:45 pm

One record per team would be my preference. For touchdowns I would try having one array per team, something like this:

Code: Select all

{
  "teams" : [
    {
      "teamName": "Team A",
      "score": 2,
      "passes": 5,
      ..., // Other team stats/coach name/race
      "touchdowns": [ // An array of 0 or more touchdowns
        {
          "scoredBy": "Player A",
          "turn": 2
        },
        ...
      ]
    },
    {
      // Team 2 details
    }
  ],
  "overallStats" : {
    "mostYardsRun" : {
      "name": "Player B",
      "value": 123
    }
  }
}


As many stats as you'd like to give would be awesome. We don't have to use them all on every image.

Yes, I was wondering about logging the matches on the website. For us it's just fine to have them in the forum, but if it was made more publicly available, it would probably be useful to be able to have them done on the site.
Image

User avatar
Gandalf
Moderator
Moderator
Posts: 2064
Joined: Sat Nov 24, 2012 1:44 am

Re: API Chatter

Postby Gandalf » Sat Feb 20, 2016 10:35 am

That looks fine to me. I'll get round to it sometime in the next 10 days. Might need a bit of fiddling around with the data to keep PHP happy.

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Thu Feb 25, 2016 10:37 am

So, I've dropped off the radar for this, but I've not forgotten about it! Some things have just been getting in the way, like building a little flying machine, being too tired after work and getting a little bit of Horizons fever so poking around in my SRV was more appealing than poking around in code (after a hard day's coding).

Things I have working:
  • SVGs work on the forum (yay);
  • I've discovered some tutorials for doing something very similar, making this much easier (or at least potentially easier - it depends how it's actually going to be hosted);
  • I've tested a JavaScript library I'd like to use, and created an SVG from it;

Things I want to do Soon™:
  • Create a "header" image with basic game details - I'll create an actual image, using image editing tools rather than code, to use as the background;
  • Add match specific information to the image using code;
  • Store created images in a DB so we don't have to pull data from BBDB everytime someone requests an image. BBDB should only be accessed the first time someone requests an image for that specific match;
  • Set up some kind of web hosting so I can actually provide this as a service. I've been meaning to do this for a while anyway.

If you have any input on the lists above, let me know, especially regarding hosting/db (Gandalf) or images (everyone).
Image

User avatar
DaigaroOgami
Very Prolific Poster
Very Prolific Poster
Posts: 830
Joined: Mon Jun 23, 2014 8:55 am

Re: API Chatter

Postby DaigaroOgami » Thu Feb 25, 2016 10:50 am

id3nt1ty wrote:Things I want to do Soon™:


The story of ID's life...

Notice how he didn't trademark 'Things I have done'

MWAHAHAHHAHAHHAHAAHA.

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Thu Feb 25, 2016 11:01 am

DaigaroOgami wrote:
id3nt1ty wrote:Things I want to do Soon™:


The story of ID's life...

Notice how he didn't trademark 'Things I have done'

MWAHAHAHHAHAHHAHAAHA.

Soon™ happens to be a little reference back to the guys who developed stuff for Allegiance, although with those guys it was always Two Weeks™.

But yes, it's the story of my life. It's a lot more interesting to have a lot of projects on the go, it means there is always something interesting to do when I get stuck/bored on one particular thing. I'm also not particularly "goal orientated" with my hobbies. Generally I do things because I enjoy doing them. If I'm not enjoying myself, I don't see a lot of point in doing something.
Image

User avatar
Gandalf
Moderator
Moderator
Posts: 2064
Joined: Sat Nov 24, 2012 1:44 am

Re: API Chatter

Postby Gandalf » Thu Feb 25, 2016 12:39 pm

id3nt1ty wrote:[*] Store created images in a DB so we don't have to pull data from BBDB everytime someone requests an image. BBDB should only be accessed the first time someone requests an image for that specific match;
[*] Set up some kind of web hosting so I can actually provide this as a service. I've been meaning to do this for a while anyway.[/list]


The impression I had regarding BBM is that it didn't generate the image when you uploaded a file, but it gave a URL for the image, and when that URL was first accessed, the image was created, and then it stayed there forever.

I'm not sure you need to store the files in a database? Though it might be useful to store some metadata there - who requested it, when, maybe when it was last accessed.

Short term I *may* be able to offer you some of my webspace. If you're interested let me know and I can investigate. Hopefully they won't take up too much space. All the data from BBDB is well into the hundereds of megabytes already and that's just from 128 games.

As for my side - the API work got pushed back due to fixing upload failures last week, which still aren't fully resolved. After I've got that fixed, it's on to team-season-stats and this. But I make no excuses for putting RL, my wife & 2 small kids first.

User avatar
Raveen
Moderator
Moderator
Posts: 2437
Joined: Thu Nov 15, 2012 12:59 pm
Location: Solihull
Contact:

Re: API Chatter

Postby Raveen » Thu Feb 25, 2016 12:47 pm

I'll do what I can with the Logo files. They're currently dwg and AutoCAD doesn't export to SVG so I need to run them through a third party application.

For what it's worth,here's the dxf file with all sorts of ideas and dead ends in it. There's all the letters for an RT Font and lots of variations on the logo. There should be something you can use.
Attachments
RT Logo.dxf
(1.9 MiB) Downloaded 8 times
ImageImage

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Thu Feb 25, 2016 12:50 pm

Rav, I have Illustrator at work so can happily convert between dwg and svg if that's easier for you? I might be able to open dwg files in inkscape anyway...

Cheer, I'll take a look.
Image

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Thu Feb 25, 2016 12:54 pm

Gandalf wrote:The impression I had regarding BBM is that it didn't generate the image when you uploaded a file, but it gave a URL for the image, and when that URL was first accessed, the image was created, and then it stayed there forever.

That's basically what I plan to do, I got that impression too.

Gandalf wrote:I'm not sure you need to store the files in a database? Though it might be useful to store some metadata there - who requested it, when, maybe when it was last accessed.

The files are just text, so it's easy enough to have them in a database. And provides easy lookup between match id and file to check it already exists. I was planning on having at least image version meta data, so that if the image changes in the future it's easy enough to force it to regenerate it.

Gandalf wrote:Short term I *may* be able to offer you some of my webspace. If you're interested let me know and I can investigate. Hopefully they won't take up too much space. All the data from BBDB is well into the hundereds of megabytes already and that's just from 128 games.

Thanks, but whilst I'm developing playing around I'd rather have my own space, so I don't have to worry about ruining someone elses...

Gandalf wrote:As for my side - the API work got pushed back due to fixing upload failures last week, which still aren't fully resolved. After I've got that fixed, it's on to team-season-stats and this. But I make no excuses for putting RL, my wife & 2 small kids first.

No worries, of course!
Image

User avatar
Raveen
Moderator
Moderator
Posts: 2437
Joined: Thu Nov 15, 2012 12:59 pm
Location: Solihull
Contact:

Re: API Chatter

Postby Raveen » Thu Feb 25, 2016 2:57 pm

id3nt1ty wrote:Rav, I have Illustrator at work so can happily convert between dwg and svg if that's easier for you? I might be able to open dwg files in inkscape anyway...

Cheer, I'll take a look.

The dxf is the same file as the DWG in a different format. Everything that can open DWG should be able to open dxf. I just can't attach DWG files to the forum.

At some point I'll build an actual font from the letters I've created. But until then you at least have the shapes.
ImageImage

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Wed Mar 02, 2016 4:04 pm

Raveen wrote:I've like to move away from the rustic feel of the BBM outputs to something that looks a bit more TV sportsy.

What do you think about the BBL2 aesthetic? I think it's a good mix of the more rustic roots of BB, but with a more TV-sportsy twist.
Image

User avatar
Gandalf
Moderator
Moderator
Posts: 2064
Joined: Sat Nov 24, 2012 1:44 am

Re: API Chatter

Postby Gandalf » Mon Mar 07, 2016 10:17 pm

OK some work has been completed here now, with the aim of making the API scalable to a mass audience.

To submit an API request now requires an API key. This is so I can monitor/track usage, prevent bots overloading the server by downloading everything, restricting what data different users can access etc etc... (I have yet to enable the tracking code but it's mostly there ready to turn on) id3 has an API key, as do I.

Requests also require a version number. Over time, versions will be deprecated. So for now, matchdetail is at version 1 and still returns what it used to do before I did this work. I will work on version 2 soon-ish (planned to change the format to what was discussed earlier in this thread). Version 1 will remain for some time as (theoretically) other users may still be using it, and it gives them time to change their code.

So, the format is....
http://gandalfgames.net/bbdb/api/matchd ... &version=1

The 3 parameters can be in any order. All 3 parameters are mandatory.

I will write this up to live on the website at some point. But for now, since the only users are myself & id3, doesn't quite seem worth it.

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Mon Mar 07, 2016 10:23 pm

Very cool
Image

User avatar
id3nt1ty
Blood Bowl Leader
Blood Bowl Leader
Posts: 1235
Joined: Sat Nov 24, 2012 10:00 pm

Re: API Chatter

Postby id3nt1ty » Tue Mar 08, 2016 6:55 am

Some security suggestions:
  • don't send the API key as a parameter in the URL. There is nothing to stop an attacker accessing this and impersonating someone else (potentially with more access rights). Additionally, if you are building a REST API, it doesn't describe the resource being requested, and makes responses difficult to cache;
  • send it in the body of the request, and require a https connection.

Also, it didn't work for me - I got some message that I can't remember. I didn't try very hard though, will try again later.
Image


Who is online

Users browsing this forum: No registered users and 0 guests