Giter Site home page Giter Site logo

api's Introduction

BukGet Build Status

BukGet is a JSON API into dev.bukkit.org. The idea is to provide some sort of an interface into DBO's contents as Curse doesn't natively have one for us to interact with.

What does it do?

BukGet is a API into dev.bukkit.org that is trying to parse out the relevant details needed to perform package management for Bukkit. We do not have a client that interacts with our API, however instead offer the API to anyone wishing to use it to build their own package management system for Bukkit. We do our best to try to parse out all of the relevant data, including dependencies, CB build numbers, etc. to help aide developers along in getting the information they need.

How do I use BukGet?

We have a JSON API that you can interact with in order to pull the information you need. Details on how to interact with the API are explained later on in this document.

How do I get my plugin included in BukGet?

Is your plugin in dev.bukkit.org? If it is, then your plugin is already included.

Where can I get more information?

Visit the Projects main website bukget.org

Arch Overview

BukGet utilizes MongoDB as the back-end database and is coded using the bottlepy web framework. For scalability, we use Paste as the application server and front-end that with Nginx for URL routing (in-case we need to stand up a dev instance) as well a logging all of the requests. This implementation framework has been able to handle 20M requests a month without showing any significant impact on the hardware (~10% CPU Utilization and ~1-2% I/OWait as of the writing of this document).

Application List

  • MongoDB
  • Python 2.6/7
  • Bottle
  • Tornado
  • Nginx

Script List

  • bukgen_bukkit
  • bukgen_manual
  • bukget
  • force_update.py
  • logreader.py

Services List

  • nginx - sysv
  • mongod - sysv
  • bukget - upstart

Services Layout (By Server)

  • dallas.api.bukget.org
    • BukGet API (Nginx, Mongo, BukGet)
    • logreader script (cronjob)
    • BukGen Generator (bukgen_* applications)
    • Maintinence Functions (force_update.py, bukgen_manual)
  • paris.api.bukget.org
    • BukGet API (Nginx, Mongo, BukGet)
  • dev.vpn.bukget.org
    • Development Services (Independent of Prod)
      • BukGet API (Nginx, Mongo, BukGet)
    • Production Database Nightly Backup

MongoDB

The Mongo Database has not had any customization that needs to be documented at this time. The Dallas server is the primary database engine, with the Paris server acting as the secondary. This means that all Database writes has to go through the Dallas Mongo instance.

Python 2.6/7

The Python Installation on the server(s) is the default installation that comes with CentOS 6.3 x64. Pip has also been installed on these hosts manually and is being used to help manage the installation of any needed dependencies as well as the installation of the bukget and bukgen packages themselves. These packages are being pulled directly from the git repository and then being updated using the following command in the appropriate directory:

pip install --upgrade ./

This will install/upgrade any dependencies for the package as well as install the latest version of the package itself.

Nginx

Below is the configuration for the VHost that we use for BukGet. Keep in mind that minor modifications may exist to also listen for the hostname as well as api.bukget.org

server {
        listen          80;
        server_name     api.bukget.org XXX.api.bukget.org;

        access_log      /var/log/bukget/api-access.log;
        error_log       /var/log/bukget/api-error.log;

        location / {
                proxy_pass              http://127.0.0.1:9132/;
                proxy_redirect          off;

                proxy_set_header                Host            $host;
                proxy_set_header                X-Real-IP       $remote_addr;
                proxy_set_header                X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_max_temp_file_size        0;

                client_max_body_size            10m;
                client_body_buffer_size         128k;

                proxy_connect_timeout           90;
                proxy_send_timeout              90;
                proxy_read_timeout              90;

                proxy_buffer_size               4k;
                proxy_buffers                   4 32k;
                proxy_busy_buffers_size         64k;
                proxy_temp_file_write_size      64k;
        }
}

bukgen_bukkit Script

This script is the main script that is being run to keep bukget up to date. This script runs every 6 hours. It can also be run manually as needed (uncommon). The script has a self-imposed 2 second delay for each URL request so not to overwhelm BukkitDev. It's still worth noting that if a generation is run outside of the normal window, to check to make sure nothing else is currently talking to BukkitDev so now to overwhelm the service we're pulling from.

BukGen also has a number of built-in safeties aside from the 2 second delay. These mechanisms have evolved over the life of the generation script and may change:

  • 2 Second Delay Timer: Delays the amount of time globally for each request to BukkitDev. This is tunable.
  • Re-pull URL on Failure: The system will automatically dwell on URLs that have failed to pull (i.e. timeout has been reached). This allows the generation script to effectively pull the required data.
  • Stop Pulling Bad Data After 3 Re-trys: If the generator receives an HTTP code other than a 200-OK (timeouts excluded) then it will attempt another 2 times. If a 200-OK is not returned, then it will fail the URL out and continue on. This prevents the generator from going into an infinite request loop.

Options

  • speedy: This is the normal run behavior. It will run through BukkitDev until it no longer finds any updates to process, then terminates.
  • full: This process will run through all of BukkitDev, ignoring any existing data and will update everything. This is generally only used when API changes of DB re-population is needed. This will take several days to complete.
  • speedy_full: Forces bukgen to look at every plugin, however will still honor any existing data for each plugin. This function effectively replaces the stage_update function and is designed to be run monthly to update any stale information about the plugin itself.
  • stage_update: Function to only update the stage value for the plugin. Rotates through all plugins in the database and will mark any deleted plugins as well as update the stage of the plugin.

bukgen_manual Script

This is a script to manually update the document to one or many plugins. There may be many reasons for doing this, however this generally relates to the generator script not being able to pull the right data (this is most common with plugins that are bundled in zip files). To run the script, first you will need to create a json file with the corrected plugin definition and place it into the directory /tmp/bukget/fixed_json. You may need to create this directory if it doesn't exist. The filename of the json files are not important, however they must have the .json extension and be only 1 plugin per json file. When ready, just run the command bukkit_manual. The script should import/update the given plugins then remove the .json files as it runs.

bukget Script

This is the bukget api launcher script. This is generally run from the upstart job, however can be manually run when debugging code to see what the errors are.

force_update.py script

This script will update the plugins specified as arguments out-of-band of the normal update cycle. This is useful when a plugin either was never updated, or the update never completed for this plugin. These occurrences are rare, however do happen from time to time.

Usage:

/opt/bukget/devfiles/force_update.py plugin_name_1 plugin_name_2

logreader.py Script

This script is designed to run nightly from a cronjob. It walks through the previous days nginx log, determines how many calls to each plugin and from each API were performed, then also updates the popularity scoring based on those. It is not recommended to run this script outside the normal schedule unless it fails as it will modify the popularity scoring for all plugins in the system.

api's People

Contributors

captainyarb avatar cjc343 avatar dmarby avatar lukegb avatar nijikokun avatar resba avatar stevemcgrath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api's Issues

Feature Request: Return totalcount for Server side pagination results.

Take an API call like this for example: http://api.bukget.org/3/plugins/?start=0&size=25. This works perfectly for retrieving the first 25 plugins. However, I would like to also display how many pages of data there is. I.E. 25 (or whatever size) / total record count = # of pages for the query.

I'd love to have a way to get this data without having to do an API call for all the data and then counting the results. Not sure if this is plausible with the way the current api is structured but this would be really helpful for displaying the data in grids/tables.

Multicraft Issue

Hi

When i've open BukGet on my Multicraft, then I got an 500 Error. How can I fix this? Has anyone other the same Problem?

Benjamin

Feature request: Search by filename.

I'd like to be able to search for a plugin by a filename, it should be able to check historic versions and return which plugin it was.

Additionally (and I realise this is somewhat more significant) - Zip files should be searched for what .jar files they contain so you can search for which plugin contains a given jar file.

Bukget.org unreachable, 503

This is not really a bug, but it's unreachable.
Is the server overloaded, or are there technical problems?
Any mirrors that could be used in between?

Greets,

Allow for a callback to be retrieved with the barebone JSON data.

This would allow admin panels to directly grab information on the fly from bukget.org's API without having to proxy it through PHP or other means.

Would probably work like this:

@app.route('/plugin/:name/:version/version/:callback')
def latest_plugin_download(name, version, callback):
response.headers['Content-Type'] = 'application/json'
for item in cache['plugins']:
if item.name == name:
if version == 'latest':
return callback + "(" + json.dumps(item.versions[0].name) + ")"
else:
for ver in item.versions:
if ver.name.lower() == version.replace('_', ' ').lower():
return json.dumps(ver.name)
return ''

Unsure if above code works, I don't code in Python.

Limiting results needs parameter start=0, or results won't be limited

When using the parameter "&size=5" (or any other count) this parameter is ignored, unless you add "&start=0"
A fix would be to set start=0 if it isn't set in the URL.

Example:
This URL will show all plugins:
http://api.bukget.org/3/plugins?fields=slug,plugin_name&sort=-popularity.weekly&size=2
This URL will only show the requested 2 plugins:
http://api.bukget.org/3/plugins?fields=slug,plugin_name&sort=-popularity.weekly&size=2&start=0

Greets,

/latest API Call broken

http://api.bukget.org/api/plugin/essentials/latest

Returns the following:

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html>
        <head>
            <title>Error 500: Internal Server Error</title>
            <style type="text/css">
              html {background-color: #eee; font-family: sans;}
              body {background-color: #fff; border: 1px solid #ddd;
                    padding: 15px; margin: 15px;}
              pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
            </style>
        </head>
        <body>
            <h1>Error 500: Internal Server Error</h1>
            <p>Sorry, the requested URL <tt>&#039;http://api.bukget.org/api/plugin/essentials/latest&#039;</tt>
               caused an error:</p>
            <pre>Internal Server Error</pre>
              <h2>Exception:</h2>
              <pre>NameError(&quot;global name &#039;versions&#039; is not defined&quot;,)</pre>
              <h2>Traceback:</h2>
              <pre>Traceback (most recent call last):
  File &quot;/usr/bin/bottle.py&quot;, line 744, in _handle
    return route.call(**args)
  File &quot;/usr/bin/bottle.py&quot;, line 1529, in wrapper
    rv = callback(*a, **ka)
  File &quot;/usr/bin/bottle.py&quot;, line 1479, in wrapper
    rv = callback(*a, **ka)
  File &quot;/usr/lib/python2.6/site-packages/bottle_sqlalchemy.py&quot;, line 128, in wrapper
    rv = callback(*args, **kwargs)
  File &quot;/usr/lib/python2.6/site-packages/bukget/legacy.py&quot;, line 85, in plugin_version
    return jsonify(getdict(plugin, version))
  File &quot;/usr/lib/python2.6/site-packages/bukget/legacy.py&quot;, line 32, in getdict
    version_name = versions[0].name
NameError: global name &#039;versions&#039; is not defined
</pre>
        </body>
    </html>

Wrong version of some plugins shown as current

Using the API, in this case through Multicraft, some plugins are showing the wrong version as the current version.

PermissionsEX is a great example. Multicraft queries the BukGet API and the version returned is "Version 2.0-SNAPSHOTby t3hk0d3, zml2008", which is very broken and will not load in CraftBukkit v1.6.2.

pex

I've emailed the developer of Multicraft and his response was this:

"The BukGet browser does not access dev.bukkit directly. Instead, it gets the information from the BukGet project: http://bukget.org/ ", so I'm opening a bug report here.

When you follow the "more" link to the dev.bukkit.org site, the correct versions are shown:

pex2

BukGet wont enable plugins

I installed bending, probending, and banhammer using BukGet and it did not enable the plugins once the server started...

Not updating plugins

i have a plugin called creative control and i checked and the latest version is 6.4 im currently using 6.3 on the server and it says that the plugin is updated. why cant i update to the current version of 6.4
bukgetupdate1
bukgetupdate2

Error 500 via Multicraft hosted

Been getting an error 500 on my multicraft hosted "BukGet Pluggins" Link. Support @ multicraft says API is down. Been down since the 12 and been waiting for it to come back up. ETA or anything?

Suggestion: Php/Js child servers

I don't know if this is possible, but it would be nice if there was some php child server functionality.
If you use Php, eventually some javascript, for child servers, more people might be able to host one.
I'd like to run a child server, but I can't because of the python requirement.
A child server could do this:
A php file, that retrieves the database from bukget.org and store it local. This file could be ran by a cron job.
Another php file, that accepts arguments in the same way as bukget.org, to retrieve info from the local database copy and print it.

So everything that would be required for this is php, sql (which you'd need always), CronJobs and some editing in your .htaccess maybe (to allow arguments in the same way, without showing ".php?arg=" or similar) .

feature request: ability to obtain an export of the raw data

I run a small Minecraft host, and while I totally love bukget, I don't love doing a lot of remote calls every time someone is browsing around for plugins to install. Since I use MongoDB as my own backend anyway, was wondering if there's an option to obtain a dump of the bukget data on a regular basis because it's much easier to dig it out locally than it is to go remote all the time.

No Content-Disposition?

Can the API return a Content-Disposition please? This is the 3rd time that broke my plugin that uses the service and this time I've got no clue how to fix it.

It just needs to download the latest file given a plugin name.

This is the code I'm using. Header is equal to null, therefore causing it to return false.

private static boolean installPlugin(String pluginName) throws IOException {
    String urlStr = "http://api.bukget.org/3/plugins/bukkit/"
            + pluginName.toLowerCase() + "/latest/download";
    URL url = new URL(urlStr);
    URLConnection con = url.openConnection();
    con.getHeaderFields();
    String header = con.getHeaderField("Content-Disposition");
    if (header == null) {
        return false;
    }
    String fileName = header.replace("attachment; filename=", "");
    File file = new File("plugins/" + fileName);
    ReadableByteChannel rbc = Channels.newChannel(con.getInputStream());
    FileOutputStream fos = new FileOutputStream(file);
    fos.getChannel().transferFrom(rbc, 0, 1 << 24);
    fos.close();
    return true;
}

Bukget formats and interfacing

Hi,

Is there any option for XML format or direct SQL access?
XML is easier to handle (.NET has built-in functionality)
Direct SQL access is also a bit handier for searching plugins. (again, because SQL is built in in many languages)

Another idea: Is it possible to show only the latest file?
by example: bukget.org/api/json?fast=true
This should only show the latest file versions.
This results in a much smaller file.
An example: Spoutcraft: 9.75kb --> 930byte
thats 10 times smaller!

greets,

Plugin search feature in MCMA broken

Plugin Search in MCMA (and I assume other interfaces) has broken results -- Under Install plugins, and you input a word to search for in the search bar, returns ALL plugins in alphabetical order, and clicking on any of those plugins does not return an install button. I spoke with PhonicUK in IRC chat and he suggested I submit a bug report here:

[16:43] I think something is wrong with the plugin search feature. It returns all plugins in alphabetical order. Known bug?
[16:43] @PhonicUK din0, I suspect the bukget author has changed something...
[16:44] @PhonicUK din0, it would seem so. bug in bukget instead of MCMA

Names are case sensitive when searching

when searching for plugin_name the actions "like", "=" and "!=" is case sensitive.
Some examples:

    http://api.bukget.org/3/search/plugin_name/=/worldedit
    http://api.bukget.org/3/search/plugin_name/like/worldedit

will not return worldedit

    http://api.bukget.org/3/search/plugin_name/!=/worldedit

contains worldedit

This is especially bad with the like function, but should be fixed for the "=" and "!=" too.

Plugin Listing with fields and sorts sometimes returns HTTP Error 500

I started testing out the GUI for bukget and I noticed that some searches are crashing out when I add certain sorting parameters. Perhaps I'm not understand the docs page correctly. Here are a few examples:

http://api.bukget.org/3/plugins/?fields=slug&sort=webpage
http://api.bukget.org/3/plugins/?fields=slug&sort=description

Did a bit more testing and it seems it will work if I specify a start and size like this:

http://api.bukget.org/3/plugins/?fields=slug&sort=webpage&start=0&size=100

I had assumed that the pagination variables were optional. Is this not the case?

Must include versions.type on 3/plugins/<server>/<slug>/{release,beta,alpha}

This issue is quite strange, and I don't completely understand how it behaves.
here is an example of things that fails, I use addsomefurniture because it has release, beta and alpha builds.

http://api.bukget.org/3/plugins/bukkit/addsomefurniture/release?fields=versions.version
http://api.bukget.org/3/plugins/bukkit/addsomefurniture/beta?fields=versions.version
http://api.bukget.org/3/plugins/bukkit/addsomefurniture/alpha?fields=versions.version

However, these works:

http://api.bukget.org/3/plugins/bukkit/addsomefurniture/latest?fields=versions.version
http://api.bukget.org/3/plugins/bukkit/addsomefurniture/release?fields=versions.version,versions.type
http://api.bukget.org/3/plugins/bukkit/addsomefurniture/beta?fields=versions.version,versions.type
http://api.bukget.org/3/plugins/bukkit/addsomefurniture/alpha?fields=versions.version,versions.type

EDIT: I found the issue. it looks like you must include the versions.type as a field when asking for release, beta or alpha version

MultiCraft

Are there any tips for integrating this into the Multicraft control panel?

.sql Database dump

Hello Steve,

would it be possible to offer a .sql (MySQL) cache as well?

Best regards,

Antariano

Add File Status To API

When uploading files to DBO, developers can choose a build status from release, beta and alpha. It would be useful if bukget stored this information with each file, so that, for example, an updater plugin could only update plugins if release builds were available, not beta or alpha versions.

Example: http://dev.bukkit.org/server-mods/uhome/files/

Idea: let logreader.py check for issues

Logreader.py checks every line from the logfile.
You could add some functionality so it also checks for errors (402/403/404/502)

err40x= re.compile(r'\s40\d\s')
err50x= re.compile(r'\s50\d\s')
....
for line...
is40x=(len(err40x.findall(line))>1)

handle 40x error

is50x=(len(err50x.findall(line))>1)

handle 50x error

next....
....

You could check for http/200 (OK), and in case this isn't found, check for errors.
Errors could be saved to an array (unique IP's?)
This array could be passed on to a function that writes malfunctions to a database table, which is read by a kind of status page?

baskit.ini

Under Ubuntu 10.04LTS, baskit does not properly locate the configuration file in ~/.baskit.ini. It only properly finds the configuration file if it is in CWD

error 500

Since the URL api change I am getting the following error for any api call

Error 500
file_get_contents(http://api.bukget.org/2/bukkit/plugin/a5h73y): failed to open stream: Connection timed out

I have tried servers in usa, europe and asia and the result is the same

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.