These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
12Next page
 

EVE.Net Library

Author
Cuhlen
Deep Core Mining Inc.
Caldari State
#1 - 2012-06-03 14:54:05 UTC  |  Edited by: Cuhlen
I've decided to release the C# library I wrote for accessing the public eve API.

While there are other .net libraries out there, none that I know of both support all of the API calls, and include the full source.

EVE.Net supports all current API calls, including the image server, contains the full C# source code and is released under the MIT library. Modify/use as you see fit.

You can download the latest release from here.


The project is written in Visual Studio 2010. You will need some version of that to compile it, though converting it to 2005 or 2008 should be trivial. The library is compiled against .NET 2.0, so it should be mono compatible, though I have not tested that.

The only API calls I could not test are the ones that deal with sovereignty and outposts. If any 0.0 corp directors get a chance to test those calls, I would appreciate it if you would let me know if they work or not.

Example use:

CharacterSheet charSheet = new CharacterSheet(keyID, vCode, charID);
charSheet.Query();

Console.WriteLine(" Name: {0}", charSheet.name);
Console.WriteLine(" ID: {0}", charSheet.characterID);
Console.WriteLine(" Date of Birth: {0}", charSheet.DoB);
Console.WriteLine(" Race: {0}", charSheet.race);
Console.WriteLine(" Bloodline: {0}", charSheet.bloodLine);


Email me with any problems you may have.

Change History

1.0 06/03/2012
Initial Release

1.1 06/24/2012
Fix for non-english unit conversion. (commas instead of decimal points, etc).

1.2 07/05/2012
Added a prefix to all cache files for api calls made against the test server.
Added a fix for unexpected 'bool.parse' method suddenly missing.
Removed the trailing '\' character from the EVEConstants.eveServerStatusUri string that was causing issues with determining the cache file name.
License changed from Boost license to MIT license (to satisfy Goole Code)
Added a try/catch around APIReader:Query for WebExceptions.

1.2.1 07/19/2012
The format of cache file names has been changed. Rather than including the entire argument line in the filename, the argument list is now encoded as an MD5 hash.
This resolves an issue where certain API calls could generate cache file names that exceeded the OS filename length limits.

Now caching the return of 'IsCorpKey' to reduce the number of unnecessary web requests.

1.2.2 08/20/2012
Adjusted 'roleID' in CharacterSheet.Role to be an Int64, per a post by Virppi Jouhinen (from the 'Elinor' project) where she indicated an out of range exception.

1.2.3 08/24/2012
Updated AccessMask to uint32
Fixed an incorrect xpath issue that was causing nested objects to not read correctly (ie: AttributeEnhancers in CharacterSheet)
Osku Rei
Pixel 6
#2 - 2012-06-06 13:19:08 UTC  |  Edited by: Osku Rei
Cuhlen wrote:
I've decided to release the C# library I wrote for accessing the public eve API.

While there are other .net libraries out there, none that I know of both support all of the API calls, and include the full source.

EVE.Net supports all current API calls, including the image server, contains the full C# source code and is released under the Boost library. Modify/use as you see fit.

You can download it from here.
EVE.Net 1.0

The project is written in Visual Studio 2010. You will need some version of that to compile it, though converting it to 2005 or 2008 should be trivial. The library is compiled against .NET 2.0, so it should be mono compatible, though I have not tested that.

The only API calls I could not test are the ones that deal with sovereignty and outposts. If any 0.0 corp directors get a chance to test those calls, I would appreciate it if you would let me know if they work or not.

Example use:

CharacterSheet charSheet = new CharacterSheet(keyID, vCode, charID);
charSheet.Query();

Console.WriteLine(" Name: {0}", charSheet.name);
Console.WriteLine(" ID: {0}", charSheet.characterID);
Console.WriteLine(" Date of Birth: {0}", charSheet.DoB);
Console.WriteLine(" Race: {0}", charSheet.race);
Console.WriteLine(" Bloodline: {0}", charSheet.bloodLine);


Email me with any problems you may have.



One thing I noticed is that you don't follow 'CamelCase' naming convention for properties (standard in all(?) CSD's, including microsofts) I havent looked at any of the code, but following a standard CSD for a public released API might be a good idea.

Next generation of lottery tracker coming soon! http://evelotterytracker.com/

Please like my post if it has helped you :)

Etil DeLaFuente
Aliastra
Gallente Federation
#3 - 2012-06-06 17:34:09 UTC  |  Edited by: Etil DeLaFuente
that's because he's using reflection to map an xml attribute to the object property. You could use the same method by declaring a custom attribute on object properties so you can respect CamelCase.

Good work otherwise, even if reflection is damn slow.
Cuhlen
Deep Core Mining Inc.
Caldari State
#4 - 2012-06-06 17:47:11 UTC
Etil DeLaFuente wrote:
that's because he's using reflection to map an xml attribute to the object property. You could use the same method by declaring a custom attribute on object properties so you can respect CamelCase.

Good work otherwise, even if reflection is damn slow.



That's exactly right.

There are a few cases in the xml that are not consistent, so I did include a custom attribute (XmlIdentifier) which could be used to do just that. In fact, that was how I started the library, but I found that I was adding the custom attribute to each public property - and I felt that besides being somewhat tedious, it needlessly complicated the library.

Anyway - library design is interesting. The decisions you make are always tradeoffs between something.

Etil DeLaFuente
Aliastra
Gallente Federation
#5 - 2012-06-06 22:01:19 UTC
All the API are read only so you could expose interfaces instead of classes and keep your implementation private. It would solve the problem without rewriting everything.
Takahiro Tanaka
Tanaka Stuff and Supplies
#6 - 2012-06-22 17:59:21 UTC
Excellent work !

I tried to extract some wallet transactions. Seems that the price of an item gets parsed without the decimal point.

For example:
Tritanium shows in the XML as follows .... price="6.28" ....
The value in the WalletTransactions.Transaction.price shows 628.00
Cuhlen
Deep Core Mining Inc.
Caldari State
#7 - 2012-06-23 22:32:58 UTC
Takahiro Tanaka wrote:
Excellent work !

I tried to extract some wallet transactions. Seems that the price of an item gets parsed without the decimal point.

For example:
Tritanium shows in the XML as follows .... price="6.28" ....
The value in the WalletTransactions.Transaction.price shows 628.00


Can you double-check this Takahiro? I am not able to reproduce the problem.

Xml output

Test result


Takahiro Tanaka
Tanaka Stuff and Supplies
#8 - 2012-06-24 11:26:57 UTC
Problem identified. It has to do with the localization settings in Windows. In my culture we use an comma instead of an dot for the decimal point, that caused the issue.

Example how it works on my machine, without the cultureinfo it would ignore the dot:

string price = "10.95";
decimal dec;
decimal.TryParse(price, NumberStyles.Number, CultureInfo.GetCultureInfo("EN"), out dec);

Also see this thread on stackoverflow.

If you could adapt your parsing process accordingly, it will work on all machines.

Thanks again for this great library !
Desmont McCallock
#9 - 2012-06-24 11:48:09 UTC
@Cuhlen
Try applying CA (Code Analysis) rules for Globalization in your project. http://msdn.microsoft.com/en-us/library/dd264912
Overall it's a good practice to CA any project.
Cuhlen
Deep Core Mining Inc.
Caldari State
#10 - 2012-06-24 20:36:57 UTC
Desmont McCallock wrote:
@Cuhlen
Try applying CA (Code Analysis) rules for Globalization in your project. http://msdn.microsoft.com/en-us/library/dd264912
Overall it's a good practice to CA any project.


That's good advice. Thanks.
I've sent Takahiro a build that should resolve the issue. I'll update things here when I hear back from him.



Cuhlen
Deep Core Mining Inc.
Caldari State
#11 - 2012-06-25 00:22:07 UTC
An update has been posted which should resolve the issue.

Thanks for the help guys.
Takahiro Tanaka
Tanaka Stuff and Supplies
#12 - 2012-06-25 09:23:28 UTC
Confirmed, I get decimal points now too Big smile

Good work, keep it up mate.
Cuhlen
Deep Core Mining Inc.
Caldari State
#13 - 2012-07-04 16:20:10 UTC
Just an update...

As I mentioned, I had considered adding a data access layer to the API. However, I would prefer to leave the EVE.Net api small and focused.

That said, I am in the process of writing an additional library which provides data access to the static database dump provided by CCP. Currently, I have the library accessing the database, and have written some basic accessor methods, such as:

public DataTable GetDataTable(string sql_query, params object[] args)

While developing all of this, I wrote a test application which I'm considering releasing as well, (with some cleanup, it would make a decent EVE application development environment). Here are some screenshots...

api test
manage accounts
sql query
docking

The sql query view has syntax highlighting for SQL and for the data tables and columns. I am still toying with the idea of adding intellisence to the editor, but that will likely be down the road a bit.

I've still got plenty of work to do on the data access layer, as I want to provide methods to convert EVE.Net results to data that is more usable in a UI. The test application is written in C# using WPF, so I will probably have the data access layer convert api results to view models that WPF can work with.

The only real gotcha to this data access layer is the size. The test application installer is nearly 80 megs, and uncompresses to around 400mb, nearly all of that is the sqlite database itself.
Cuhlen
Deep Core Mining Inc.
Caldari State
#14 - 2012-07-15 18:14:16 UTC
v1.2 has been released to resolve an issue with a 'Method not found' exception for bool.Parse.
Cuhlen
Deep Core Mining Inc.
Caldari State
#15 - 2012-07-19 14:24:06 UTC
Update posted that resolves an issue with cache file names being too long in certain cases. (very long argument strings for api requests).

Cryten Jones
Advantage Inc
#16 - 2012-08-13 21:17:16 UTC
Hi there.

I am VERY new to C# etc and was looking for a pointer. I have learned enough PHP, SQL and javascript on my own to use the PHP based api's but I want to have a play with some windows based stuff.

My issue is I have no idea what to do with the eve.net zip. I am assuming that I need to compile the contents and then make it available to my actual project...

I am using Vis Studio Express for C#

Any help would be much appreciated.

Thanks
Cuhlen
Deep Core Mining Inc.
Caldari State
#17 - 2012-08-14 19:56:48 UTC
Cryten Jones wrote:

I am VERY new to C# etc and was looking for a pointer. I have learned enough PHP, SQL and javascript on my own to use the PHP based api's but I want to have a play with some windows based stuff.

My issue is I have no idea what to do with the eve.net zip. I am assuming that I need to compile the contents and then make it available to my actual project...


In a nutshell, yes.

The zip file contains a visual studio project file 'Eve.Net.csproj' that you can add to your Visual Studio solution. You will need to essentially;

(In Visual Studio)
Create a solution for your project. This will create a solution file and a project file for your project.
In the solution explorer, 'add|existing', browse to the eve.net project file you downloaded and add that.
In your solution, you should now have both projects. Under your new one, right click and select 'add reference', select the 'projects' tab and select Eve.Net

You should now be able to use the eve.net library in your project.

Alternately, at the eve.net project wiki you can download the entire source project which includes an 'AppTemplate' visual studio solution which I use to test Eve.Net - you can use that as a starting point for your own project. There are instructions on the wiki page (under the 'Source' option) for downloading the code that way.


Virppi Jouhinen
Xiphias Ltd.
#18 - 2012-08-15 14:25:48 UTC  |  Edited by: Virppi Jouhinen
Looks very interesting, might switch Elinor to your lib.

102KB is a very convincing argument vs the 6MB lib I currently use.
Cuhlen
Deep Core Mining Inc.
Caldari State
#19 - 2012-08-15 16:45:06 UTC
Virppi Jouhinen wrote:
Looks very interesting, might switch Elinor to your lib.

102KB is a very convincing argument vs the 6MB lib I currently use.


That's a pretty significant difference. I can only guess that you must get alot more functionality. If all you need though is direct API access (no database information), then yeah, Eve.Net is pretty lightweight. For me though, the argument always came back to the source code. I just don't like using libraries that I don't have the source to.



Cryten Jones
Advantage Inc
#20 - 2012-08-17 10:35:42 UTC
Thanks for the help :-)

-CJ


12Next page